diff --git a/Dockerfile b/Dockerfile index c808df1..325d53d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,8 +27,8 @@ RUN rm -rf ./* # Copy the compiled static assets FROM THE BUILDER STAGE COPY --from=builder /app/dist/ . -# Copy your custom Nginx configuration -COPY nginx.conf /etc/nginx/nginx.conf +# Copy the Nginx configuration as a template so env variables (like HASURA_ADMIN_SECRET) are substituted at runtime +COPY nginx.conf /etc/nginx/templates/default.conf.template EXPOSE 80 diff --git a/index.html b/index.html index e242bc8..c24383d 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - nearledaily + Nearle Daily
diff --git a/nginx.conf b/nginx.conf index f1a121b..17cca20 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,18 +1,25 @@ -events {} +server { + listen 80; + server_name localhost; -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; + # Serve the React App + location / { + root /usr/share/nginx/html; + index index.html index.htm; + # Force Nginx to pass routing back to React Router + try_files $uri $uri/ /index.html; + } - server { - listen 80; - server_name localhost; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - # This line forces Nginx to pass routing back to React Router - try_files $uri $uri/ /index.html; - } + # Proxy /hasura to the live API, exactly like Vite dev server does + location /hasura/ { + proxy_pass https://api.workolik.com/api/rest/; + proxy_set_header x-hasura-admin-secret "${HASURA_ADMIN_SECRET}"; + proxy_ssl_server_name on; + + # Pass standard proxy headers + proxy_set_header Host api.workolik.com; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; } }