From e5ad85da828c41b7482482bb6929988278df1f70 Mon Sep 17 00:00:00 2001 From: Tomas Mirchev Date: Thu, 26 Jun 2025 20:09:58 +0000 Subject: [PATCH] update --- static-provider/nginx.conf | 39 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/static-provider/nginx.conf b/static-provider/nginx.conf index af83411..fd39eed 100644 --- a/static-provider/nginx.conf +++ b/static-provider/nginx.conf @@ -3,24 +3,27 @@ server { server_name localhost; root /static-files; - if ($request_method = 'OPTIONS') { - add_header Access-Control-Allow-Origin "*" always; - add_header Access-Control-Allow-Methods "GET, OPTIONS" always; - add_header Access-Control-Allow-Headers "Origin, Content-Type, Accept, Authorization" always; - return 204; - } - - # Only serve markdown files - location ~* \.md$ { - try_files $uri =404; - add_header Content-Type "text/markdown; charset=utf-8" always; - add_header Access-Control-Allow-Origin "*" always; - add_header Access-Control-Allow-Methods "GET, Options" always; - add_header Access-Control-Allow-Headers "Origin, Content-Type, Accept, Authorization" always; - } - - # Return 404 for everything else location / { - return 404; + # Handle preflight requests first + if ($request_method = 'OPTIONS') { + add_header Access-Control-Allow-Origin "*" always; + add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always; + add_header Access-Control-Allow-Headers "Origin, Content-Type, Accept, Authorization" always; + add_header Access-Control-Max-Age 3600 always; + return 204; + } + + # Serve static files + try_files $uri $uri/ =404; + + # Add CORS headers for actual requests + add_header Access-Control-Allow-Origin "*" always; + add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always; + add_header Access-Control-Allow-Headers "Origin, Content-Type, Accept, Authorization" always; + + # Set proper content type for markdown files + location ~* \.md$ { + add_header Content-Type "text/markdown; charset=utf-8"; + } } }