diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 9cd0d92..b2f541f 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -51,16 +51,18 @@ http { server_name "api.cors-school.nilstrieb.dev"; location / { + add_header 'Access-Control-Allow-Origin' 'https://cors-school.nilstrieb.dev'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,token,refresh-token'; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' 'https://cors-school.nilstrieb.dev'; - add_header 'Access-Control-Allow-Credentials' 'true'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,token,refresh-token'; - add_header 'Content-Type' 'text/plain charset=UTF-8'; - add_header 'Content-Length' 0; return 204; } + proxy_pass http://cors-school-backend:8080/; } }