Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- textserver {
- listen 80;
- server_name localhost;
- root /usr/share/nginx/html;
- index index.html;
- # Serve Frontend
- location / {
- try_files $uri $uri/ /index.html;
- }
- # Proxy API with Forced CORS Headers
- location /api/ {
- proxy_pass http://backend:3000;
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection 'upgrade';
- proxy_set_header Host $host;
- proxy_cache_bypass $http_upgrade;
- # --- UPDATE THESE VALUES ---
- add_header 'Access-Control-Allow-Origin' 'http://<NAS_IP>:<PORT>' always;
- add_header 'Access-Control-Allow-Credentials' 'true' always;
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
- add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With' always;
- if ($request_method = 'OPTIONS') {
- add_header 'Access-Control-Allow-Origin' 'http://<NAS_IP>:<PORT>' always;
- add_header 'Access-Control-Allow-Credentials' 'true' always;
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
- add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With' always;
- add_header 'Content-Length' 0;
- add_header 'Content-Type' 'text/plain charset=UTF-8';
- return 204;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment