sllkevin's avatar

sllkevin wrote a reply+100 XP

4mos ago

Is it normal for 404.blade to respond as 301?

That's my thinking, but shouldn't bots and crawlers or curl pings receive a proper 404 response? I just checked the standard Laravel 404 (dark 404 | NOT FOUND page) and the response is 404 in dev tools. But my custom 404.blade is 301.

sllkevin's avatar

sllkevin started a new conversation+100 XP

4mos ago

Is it normal for 404.blade to respond as 301?

When using the browser network tools, I can see that any missing route originally reveals 404 before the official response as a 301 redirect to the 404.blade template.

However, I'm checking my Nginx access logs and all the bots pinging random wordpress routes all show the response as 301. Is this normal behavior?

sllkevin's avatar

sllkevin wrote a reply+100 XP

5mos ago

Livewire - manipulate data before validation

I discovered this topic after having a similar issue. However, updatingProperty($value) does not seem to work with my scenario where I'm using #[Validate] attribute on the property for a domain URL in a simple Volt component.

In my case, I wrote a function to ensure "https://" is prefixed to a string before validating, otherwise the validation will fail immediate, on blur. I wanted to format that string before validation.

My solution is to call the filter function in the rules() method just before returning the rules array. See summary of my solution below:

#[Validate]
public ?string $domain;

protected function rules()
{
	$this->domain = isset($this->domain) 
		? Application::formatDomainString($this->domain) : null;

	return [
		'domain' => 
'nullable:string|url:http,https|unique:applications,domain,'.$this->application->id,
	];
}
<flux:input wire:model.blur="domain" />