28 lines
1.0 KiB
Plaintext
28 lines
1.0 KiB
Plaintext
server {
|
|
listen 80 default_server;
|
|
listen [::]:80 default_server;
|
|
server_name _;
|
|
|
|
root /var/www/html;
|
|
index index.html;
|
|
|
|
# These are fine at the server level, but safer inside location
|
|
add_header Access-Control-Allow-Origin "*" always;
|
|
add_header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS" always;
|
|
add_header Access-Control-Allow-Headers "Authorization, Content-Type, Accept, Origin, X-Requested-With" always;
|
|
|
|
location / {
|
|
# Handle the OPTIONS (Preflight) request correctly
|
|
if ($request_method = OPTIONS) {
|
|
add_header Access-Control-Allow-Origin "*" always;
|
|
add_header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS" always;
|
|
add_header Access-Control-Allow-Headers "Authorization, Content-Type, Accept, Origin, X-Requested-With" always;
|
|
add_header Content-Length 0;
|
|
add_header Content-Type text/plain;
|
|
return 204;
|
|
}
|
|
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
}
|