Fix frontend static asset redirect loops - add proper nginx config for /assets/ directory
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
e46c393c8c
commit
047a910ce4
@ -39,15 +39,24 @@ RUN echo 'server {' > /etc/nginx/conf.d/default.conf && \
|
||||
echo ' gzip_min_length 1024;' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo '' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' location / {' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' try_files $uri $uri/ /index.html;' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' }' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo '' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' # Cache static assets' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|webp)$ {' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' # Serve static assets directly (no fallback to index.html)' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' location /assets/ {' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' try_files $uri =404;' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' expires 1y;' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' add_header Cache-Control "public, immutable";' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' }' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo '' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' # Cache other static assets' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|webp)$ {' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' try_files $uri =404;' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' expires 1y;' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' add_header Cache-Control "public, immutable";' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' }' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo '' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' # SPA fallback for all other routes' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' location / {' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' try_files $uri $uri/ /index.html;' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo ' }' >> /etc/nginx/conf.d/default.conf && \
|
||||
echo '}' >> /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copy built files from build stage
|
||||
|
||||
@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
base: '/',
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user