Skip to content

Commit afab3e2

Browse files
committed
feat: vite 개발서버 관련 프록시 작성
1 parent e73d7bf commit afab3e2

File tree

1 file changed

+47
-4
lines changed

1 file changed

+47
-4
lines changed

services/nginx/conf.d/default.conf

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,30 @@ server {
1111
ssl_certificate /etc/nginx/ssl/localhost.crt;
1212
ssl_certificate_key /etc/nginx/ssl/localhost.key;
1313

14-
# Frontend static files
14+
# Frontend dev server
1515
location / {
16-
root /usr/share/nginx/html;
17-
try_files $uri $uri/ /index.html;
18-
add_header Cache-Control "no-cache";
16+
proxy_pass http://backend:5173;
17+
proxy_http_version 1.1;
18+
proxy_set_header Upgrade $http_upgrade;
19+
proxy_set_header Connection 'upgrade';
20+
proxy_set_header Host $host;
21+
proxy_cache_bypass $http_upgrade;
22+
23+
# HMR을 위한 설정
24+
proxy_set_header X-Real-IP $remote_addr;
25+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
26+
proxy_read_timeout 1800;
27+
proxy_connect_timeout 1800;
28+
}
29+
30+
# Vite HMR WebSocket
31+
location /hmr {
32+
proxy_pass http://backend:5173;
33+
proxy_http_version 1.1;
34+
proxy_set_header Upgrade $http_upgrade;
35+
proxy_set_header Connection "upgrade";
36+
proxy_set_header Host $host;
37+
proxy_cache_bypass $http_upgrade;
1938
}
2039

2140
# Backend API
@@ -36,4 +55,28 @@ server {
3655
proxy_set_header Connection "Upgrade";
3756
proxy_set_header Host $host;
3857
}
58+
59+
# Vite static assets
60+
location /@fs/ {
61+
proxy_pass http://backend:5173;
62+
proxy_http_version 1.1;
63+
proxy_set_header Host $host;
64+
}
65+
66+
location /@vite/ {
67+
proxy_pass http://backend:5173;
68+
proxy_http_version 1.1;
69+
proxy_set_header Host $host;
70+
}
71+
72+
# CORS preflight requests
73+
location = /api/preflight {
74+
add_header 'Access-Control-Allow-Origin' '*';
75+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
76+
add_header 'Access-Control-Allow-Headers' '*';
77+
add_header 'Access-Control-Max-Age' 1728000;
78+
add_header 'Content-Type' 'text/plain charset=UTF-8';
79+
add_header 'Content-Length' 0;
80+
return 204;
81+
}
3982
}

0 commit comments

Comments
 (0)