fix: static assets MIME type and 404 handling in nginx.conf
This commit is contained in:
+14
-6
@@ -2,14 +2,22 @@ server {
|
|||||||
listen 80;
|
listen 80;
|
||||||
server_name _;
|
server_name _;
|
||||||
|
|
||||||
location / {
|
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html index.htm;
|
index index.html;
|
||||||
try_files $uri $uri/ /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;
|
||||||
|
try_files $uri =404;
|
||||||
|
expires 30d;
|
||||||
|
add_header Cache-Control "public, no-transform";
|
||||||
}
|
}
|
||||||
|
|
||||||
error_page 500 502 503 504 /5x.x.html;
|
# SPA routing fallback for app routes
|
||||||
location = /5x.x.html {
|
location / {
|
||||||
root /usr/share/nginx/html;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user