【发布时间】:2023-01-12 06:12:12
【问题描述】:
我使用 nextjs 作为前端,使用 django 作为后端
在开发阶段一切正常
但在生产中 raise /_next/static/chunks ... 403 Forbidden Error
我的 nginx 配置不能正常工作
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name <server_name> <www.server_name>;
index index.html index.htm index.nginx-debian.html;
root /{my_dir}/client/.next/;
location /static {
proxy_pass http://localhost:3000;
# For testing cache - remove before deploying to production
# add_header X-Cache-Status $upstream_cache_status;
}
location /_next/static {
#proxy_cache STATIC;
proxy_pass http://localhost:3000;
# For testing cache - remove before deploying to production
# add_header X-Cache-Status $upstream_cache_status;
}
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
我尝试了不同的 nginx 配置
- 谁能帮帮我?
【问题讨论】:
标签: javascript node.js reactjs nginx next.js