From 7acd1bc5a1a5eb4f757c1ec391e7ad0783884504 Mon Sep 17 00:00:00 2001 From: Andrii Arsenin Date: Tue, 14 Apr 2026 13:05:55 +0300 Subject: [PATCH] feat(client): add nginx config for SPA routing and API proxy - add try_files fallback to serve index.html for all non-asset paths - proxy /api/ requests to the server container to avoid HTML being returned by nginx for API calls when using full route paths --- client/Dockerfile | 1 + client/nginx.conf | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 client/nginx.conf diff --git a/client/Dockerfile b/client/Dockerfile index b33496f..0510426 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -15,5 +15,6 @@ RUN npm run -w client build FROM nginx:alpine AS runtime COPY --from=builder /app/client/dist /usr/share/nginx/html +COPY client/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 diff --git a/client/nginx.conf b/client/nginx.conf new file mode 100644 index 0000000..8831feb --- /dev/null +++ b/client/nginx.conf @@ -0,0 +1,17 @@ +server { + listen 80; + root /usr/share/nginx/html; + index index.html; + + location /api/ { + proxy_pass http://server:3000; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + try_files $uri $uri/ /index.html; + } +}