Adding CORS headers to Laravel Valet

November 23rd, 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:

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

Don't forget to restart nginx after

valet restart nginx

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

MENU