CORS setup with custom FILAMENT_DOMAIN

Hello guys, How can I setup the Laravel CORS settings when using a subdomain to access filament? When I try to see the uploaded images I get this error: Access to fetch at 'http://FILAMENT_DOMAIN.test/medias/160/8066_zaino-vespa-v-stripes-a-tracolla-colore-nero-giallo_1695202495_.png' from origin 'http://admin.FILAMENT_DOMAIN.test' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. I have tried to edit the cors.php in all possible ways without success. Any hints? Thanks!
7 Replies
Patrick Boivin
Patrick Boivinβ€’15mo ago
Can you share your cors.php? You can redact any sensitive information.
giuseppemastrodonato
giuseppemastrodonatoOPβ€’15mo ago
Currently my cors is like this but I've tried so may combos πŸ˜… <?php return [ /* |-------------------------------------------------------------------------- | Cross-Origin Resource Sharing (CORS) Configuration |-------------------------------------------------------------------------- | | Here you may configure your settings for cross-origin resource sharing | or "CORS". This determines what cross-origin operations may execute | in web browsers. You are free to adjust these settings as needed. | | To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS | */ 'paths' => ['api/*', 'sanctum/csrf-cookie'], 'allowed_methods' => ['*'], 'allowed_origins' => ['*'], 'allowed_origins_patterns' => [], 'allowed_headers' => ['*'], 'exposed_headers' => [], 'max_age' => 0, 'supports_credentials' => false, ];
Patrick Boivin
Patrick Boivinβ€’15mo ago
Ok, I'm far from being an expert on this so maybe others can offer more insight... My first thought would be to try this:
'paths' => ['media/*', 'api/*', 'sanctum/csrf-cookie'],
'paths' => ['media/*', 'api/*', 'sanctum/csrf-cookie'],
giuseppemastrodonato
giuseppemastrodonatoOPβ€’15mo ago
already tried with that...still not working :/
toeknee
toekneeβ€’15mo ago
You are accessing images directly without going through Laravel so you would need to set the headers in the serverside config
giuseppemastrodonato
giuseppemastrodonatoOPβ€’15mo ago
Thanks for your feedback. Ho can I set the headers in laravel sail and Forge? πŸ™‚
toeknee
toekneeβ€’15mo ago
You can edit the nginx config and do it that way
Want results from more Discord servers?
Add your server