CORS problem when switching to HTTPS for local dev

Access to script at 'http://localhost/js/filament/tables/components/table.js?v=3.2.140.0' from origin 'https://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to script at 'http://localhost/js/filament/tables/components/table.js?v=3.2.140.0' from origin 'https://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I have changed .env to https://localhost Using Caddy as reverse proxy. I have pushed this build to production and worked perfectly with https and filament. so something with https and localhost
6 Replies
Dennis Koch
Dennis Koch2w ago
Usually .env should be enough. You cleared the config cache? You don't have a ASSET_URL, do you? If nothing helps URL::forceScheme('https) in a ServiceProvider is the last resort
claude
claudeOP2w ago
I've not set ASSET_URL, should I?
Dennis Koch
Dennis Koch2w ago
I think if it's unset it should use APP_URL as a default
claude
claudeOP2w ago
I'll try URL::forceScheme('https)
public function boot(): void
{ URL::forceScheme('https);
}
public function boot(): void
{ URL::forceScheme('https);
}
?
Dennis Koch
Dennis Koch2w ago
The closing ' is missing but otherwise yes
claude
claudeOP2w ago
the reason I installed HTTPS on localhost is because when I put my laravel server behind reverse_proxy (caddy) file uploads started saying 'CSRF mismatch error' so I thought, since it worked perfectly in production I'll just try http on localhost but, now when I try to upload a file, I'm getting 401 unauthorized BUT it seems the CSRF problem is fixed

Did you find this page helpful?