Nginx React/Vue SPA ?
SPA Nginx, New 404
Solutions
try_filesRecommended
server { listen 80; server_name app.example.com; root /var/www/app/dist; index index.html; location / { try_files $uri $uri/ /index.html; } # location ~* \.(css|js|jpg|png|woff2)$ { expires 1y; add_header Cache-Control "public, immutable"; }
}try_files, index.html,.
: SPA (React, Vue, Angular)
Docker
# Dockerfile FROM node:18-alpine AS build WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM nginx:alpine COPY --from=build /app/dist /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]
, Nginx. Nginx +,.
:, CI/CD