Fix · nginx
Fix “CORS policy” on nginx
Never echo back the request Origin. Allow only a fixed list of your own origins, and only send credentials to those.
# Never reflect $http_origin. Allow one fixed origin:
add_header Access-Control-Allow-Origin "https://yourapp.com" always;
Verify the fix
Re-run the CORS policy check after deploying. Test config changes in staging first and keep a rollback: a wrong header can break a site faster than a missing one.
Other stacks: Apache · Caddy · Express / Node · Cloudflare