MerryChristmas's avatar

How to allow CORS in storage folder for the files?

I need to allow CORS in storage folder, to be specific storage/app/public/uploads and all it's subfolders.

I tried to put into public/.htaccess this and similar variations of this, but nothing works. When I visit file in the browser it's actual URL is example.com/storage/uploads/../.../file.json not exactly storage/app/public/uploads so I don't know if it has anything to do with it.

<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
    Header set Access-Control-Allow-Methods "POST, GET, OPTIONS, PUT, DELETE"
    Header set Access-Control-Allow-Headers "Content-Type, X-Requested-With"
</IfModule>

0 likes
2 replies
ErmishinD's avatar

You can try to add storage/uploads path into your config/cors.php file

<?php
return [
    'paths' => ['api/*', 'sanctum/csrf-cookie', 'storage/uploads'],
	// ...
];
roozmehr's avatar

have you found a solution? I'm facing a similar problem

Please or to participate in this conversation.