From 0bfbe6e9f24bbb5308968de927e0be83236dc6e8 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Mon, 29 Sep 2025 01:03:26 +0300 Subject: [PATCH] Refactor SPA fallback handling in nginx configuration for improved routing --- nginx.conf | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/nginx.conf b/nginx.conf index 52f4947..fbb061a 100644 --- a/nginx.conf +++ b/nginx.conf @@ -51,15 +51,11 @@ http { add_header Cache-Control "public, immutable"; } - # SPA fallback - catch all routes and serve appropriate index.html + # SPA fallback - handle client-side routing for React apps location / { - try_files $uri $uri/ @fallback; - } - - # Fallback handler for SPA routes - location @fallback { - # Try to find index.html in the same directory structure - try_files $uri/index.html /index.html; + # First try to serve request as file, then as directory + # If both fail, serve index.html for SPA routing + try_files $uri $uri/ /index.html; } # Health check endpoint