Skip to content

Instantly share code, notes, and snippets.

@komputronika
Created March 1, 2024 13:59
Show Gist options
  • Save komputronika/5f2de70e7521759b454dfbbfebd425b8 to your computer and use it in GitHub Desktop.
Save komputronika/5f2de70e7521759b454dfbbfebd425b8 to your computer and use it in GitHub Desktop.
NGINX Configuration: CORS and URL Rewrite
location /Folder {
add_header 'Access-Control-Allow-Origin' '*' always;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' "*" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Headers' "Authorization, Origin, X-Requested-With, Content-Type, Accept" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
try_files $uri $uri/ /Folder/index.php$is_args$args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment