Skip to content

Commit 6462852

Browse files
committed
feat: Update environment variables and Nginx configuration for improved API handling
- Added NUXT_PUBLIC_BASE_URL and updated NUXT_SSR_API_BASE_URL in both local and production docker-compose files for better API endpoint management. - Enhanced nuxt.config.ts to utilize the new SSR API base URL for server-side rendering. - Updated Nginx configuration to include additional proxy headers for improved request handling and forwarding.
1 parent e2055ce commit 6462852

5 files changed

Lines changed: 18 additions & 1 deletion

File tree

docker-compose.local.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ services:
6565
environment:
6666
- NODE_ENV=${NODE_ENV:-development}
6767
- NUXT_API_BASE_URL=/api/
68-
- NUXT_SSR_API_BASE_URL=http://localhost/api/
68+
- NUXT_PUBLIC_BASE_URL=http://localhost
69+
- NUXT_SSR_API_BASE_URL=http://localhost/api
6970
- PORT=8080
7071
- NITRO_PORT=8080
7172
depends_on:

docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ services:
4949
environment:
5050
- NODE_ENV=production
5151
- NUXT_API_BASE_URL=/api/
52+
- NUXT_PUBLIC_BASE_URL=https://goranee.ir
53+
- NUXT_SSR_API_BASE_URL=https://goranee.ir/api
5254
depends_on:
5355
- server
5456
networks:

end_user/nuxt.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export default defineNuxtConfig({
2424
apiBaseUrl: process.env.NUXT_API_BASE_URL || process.env.VITE_API_BASE_URL || '/api/',
2525
// @ts-ignore
2626
baseUrl: process.env.NUXT_PUBLIC_BASE_URL || process.env.BASE_URL || 'https://goranee.ir',
27+
// @ts-ignore
28+
ssrApiBaseUrl: process.env.NUXT_SSR_API_BASE_URL || process.env.VITE_SSR_API_BASE_URL || 'https://goranee.ir/api',
2729
},
2830
},
2931

nginx/default.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ server {
9696
location / {
9797
proxy_pass http://end_user:8080;
9898
proxy_http_version 1.1;
99+
proxy_set_header Host $host;
100+
proxy_set_header X-Real-IP $remote_addr;
101+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
102+
proxy_set_header X-Forwarded-Proto $scheme;
103+
proxy_set_header X-Forwarded-Host $host;
104+
proxy_set_header X-Forwarded-Port $server_port;
99105
proxy_set_header Upgrade $http_upgrade;
100106
proxy_set_header Connection 'upgrade';
101107
proxy_cache_bypass $http_upgrade;

nginx/default.local.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ server {
7373
location / {
7474
proxy_pass http://end_user:8080;
7575
proxy_http_version 1.1;
76+
proxy_set_header Host $host;
77+
proxy_set_header X-Real-IP $remote_addr;
78+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
79+
proxy_set_header X-Forwarded-Proto $scheme;
80+
proxy_set_header X-Forwarded-Host $host;
81+
proxy_set_header X-Forwarded-Port $server_port;
7682
proxy_set_header Upgrade $http_upgrade;
7783
proxy_set_header Connection 'upgrade';
7884
proxy_cache_bypass $http_upgrade;

0 commit comments

Comments
 (0)