fix(shop): use production API via same-origin nginx proxy
continuous-integration/drone/push Build is passing

Hardcoded localhost:5000 broke shop.zea.lt; wire env fileReplacements
and proxy /api + /uploads to the API container.
This commit is contained in:
miczek committed 2026-10-15 05:15:10 +03:00
1 parent e6f216a63d
commit 81f8ac0215
10 files changed
+60 -7

No files matched your search

+2
View File
@@ -79,6 +79,7 @@ services:
depends_on: depends_on:
- api - api
networks: networks:
- iled
- homelab - homelab
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
@@ -95,6 +96,7 @@ services:
depends_on: depends_on:
- api - api
networks: networks:
- iled
- homelab - homelab
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
+19
View File
@@ -4,6 +4,25 @@ server {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html; index index.html;
# Browser calls same-origin /api and /uploads; proxy to API container.
location /api/ {
proxy_pass http://api:8080/api/;
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;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /uploads/ {
proxy_pass http://api:8080/uploads/;
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;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / { location / {
try_files $uri $uri/ /index.html; try_files $uri $uri/ /index.html;
} }
+7 -1
View File
@@ -47,7 +47,13 @@
"maximumError": "8kB" "maximumError": "8kB"
} }
], ],
"outputHashing": "all" "outputHashing": "all",
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.production.ts"
}
]
}, },
"development": { "development": {
"optimization": false, "optimization": false,
+5 -3
View File
@@ -1,3 +1,5 @@
export const API_URL = 'http://localhost:5000/api/v1'; import { environment } from '../../environments/environment';
export const API_BASE_URL = 'http://localhost:5000';
export const SHOP_URL = 'http://localhost:4200'; export const API_URL = environment.apiUrl;
export const API_BASE_URL = environment.apiBaseUrl;
export const SHOP_URL = environment.shopUrl;
@@ -0,0 +1,7 @@
export const environment = {
production: true,
// Same-origin; nginx proxies /api and /uploads to the API service.
apiUrl: '/api/v1',
apiBaseUrl: '',
shopUrl: 'https://shop.zea.lt',
};
@@ -0,0 +1,6 @@
export const environment = {
production: false,
apiUrl: 'http://localhost:5000/api/v1',
apiBaseUrl: 'http://localhost:5000',
shopUrl: 'http://localhost:4200',
};
+7 -1
View File
@@ -47,7 +47,13 @@
"maximumError": "8kB" "maximumError": "8kB"
} }
], ],
"outputHashing": "all" "outputHashing": "all",
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.production.ts"
}
]
}, },
"development": { "development": {
"optimization": false, "optimization": false,
+4 -2
View File
@@ -1,6 +1,8 @@
export const API_URL = 'http://localhost:5000/api/v1'; import { environment } from '../../environments/environment';
export const API_BASE_URL = 'http://localhost:5000'; export const API_URL = environment.apiUrl;
export const API_BASE_URL = environment.apiBaseUrl;
export const SESSION_KEY = 'iled_session'; export const SESSION_KEY = 'iled_session';
@@ -1,6 +1,8 @@
export const environment = { export const environment = {
production: true, production: true,
// Same-origin; nginx proxies /api and /uploads to the API service.
apiUrl: '/api/v1', apiUrl: '/api/v1',
apiBaseUrl: '',
openPanelApiUrl: '', openPanelApiUrl: '',
openPanelClientId: '', openPanelClientId: '',
}; };
+1
View File
@@ -1,6 +1,7 @@
export const environment = { export const environment = {
production: false, production: false,
apiUrl: 'http://localhost:5000/api/v1', apiUrl: 'http://localhost:5000/api/v1',
apiBaseUrl: 'http://localhost:5000',
// Set after deploying OpenPanel (self-host) and creating a client: // Set after deploying OpenPanel (self-host) and creating a client:
// openPanelApiUrl: 'http://localhost:3000/api', // openPanelApiUrl: 'http://localhost:3000/api',
openPanelApiUrl: '', openPanelApiUrl: '',