From 64a606c438c92ba448eaf8ff4da4690f032ef826 Mon Sep 17 00:00:00 2001 From: Hikmet Date: Fri, 7 Aug 2026 17:39:14 +0300 Subject: [PATCH] fix: static assets MIME type and 404 handling in nginx.conf --- nginx.conf | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/nginx.conf b/nginx.conf index 1255afe..b9c37aa 100644 --- a/nginx.conf +++ b/nginx.conf @@ -2,14 +2,22 @@ server { listen 80; server_name _; - location / { + root /usr/share/nginx/html; + index index.html; + + # Ensure proper MIME types for JavaScript, CSS, etc. + include /etc/nginx/mime.types; + + # Serve static assets directly + location /assets/ { root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html; + try_files $uri =404; + expires 30d; + add_header Cache-Control "public, no-transform"; } - error_page 500 502 503 504 /5x.x.html; - location = /5x.x.html { - root /usr/share/nginx/html; + # SPA routing fallback for app routes + location / { + try_files $uri $uri/ /index.html; } }