diff --git a/apps/client/Dockerfile b/apps/client/Dockerfile index 252f3a5..3c4d2ca 100644 --- a/apps/client/Dockerfile +++ b/apps/client/Dockerfile @@ -6,6 +6,7 @@ RUN npm ci && npm run build --workspaces --if-present FROM nginx:alpine AS runner WORKDIR /usr/share/nginx/html COPY --from=builder /app/apps/client/dist . +COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] diff --git a/apps/client/nginx.conf b/apps/client/nginx.conf new file mode 100644 index 0000000..76b87a6 --- /dev/null +++ b/apps/client/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Handle client-side routing + location / { + try_files $uri $uri/ /index.html; + } + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # Security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; +} diff --git a/apps/client/vite.config.ts b/apps/client/vite.config.ts index 21ecaea..84ef372 100644 --- a/apps/client/vite.config.ts +++ b/apps/client/vite.config.ts @@ -7,6 +7,12 @@ export default defineConfig({ server: { port: 5173, host: true, + historyApiFallback: true, + }, + preview: { + port: 5173, + host: true, + historyApiFallback: true, }, assetsInclude: ["**/*.graphql"], resolve: {