Adding CORS headers to Laravel Valet

November 23, 2022

When working on a project with subdomains, you can run into CORS issues locally when using Laravel Valet when your assets are on the main domain.

You can solve this by creating a file at ~/.config/valet/Nginx/cors.conf that contains the following:

 1# CORS Rules
 2add_header Access-Control-Allow-Origin *;
 3# END of CORS Rules #

Don't forget to restart nginx after

 1valet restart nginx

I found the solution in this issue after having to search a while for it.

MENU