部署Strapi到VPS登录时/i18n/locales接口返回404错误
环境信息
- 前端:gatsbyJS
- 后端:strapi、mysql、nginx
- Strapi版本:4.2.3
- 操作系统:Ubuntu v20.04.4 LTS或v18、v22
- 数据库:mysql v8.0.30
- Node版本:v14.20.0或v16
- NPM版本:6.14.17
- Yarn版本:1.22.19
问题描述
本地开发时npm run start和npm run develop均正常运行,部署到AWS EC2(t2.small)也能正常使用,但部署到国内某小型服务商的VPS后,登录管理页面触发404错误。
从GitHub克隆项目后,能正常访问管理页面(http://example.com/admin 或 http://示例IP/admin),但登录时出错,无法进入管理面板,其他接口响应均正常。
即使通过npx create-strapi-app重新创建项目部署,仍会出现相同错误;将本地数据库迁移到该VPS后,问题依旧。而部署到AWS EC2时,该错误自行消失。
有没有遇到过相同问题或了解相关原因的开发者?
Nginx配置
server{ listen 80; listen [::]:80; server_name example.com; root /srv/my-project/frontend/public; index index.html index.htm index.nginx-debian.html; location / { try_files $uri $uri/ =404; } location /admin { 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; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_redirect off; proxy_http_version 1.1; proxy_cache_bypass $http_upgrade; proxy_pass http://localhost:1337/admin; } }
内容的提问来源于stack exchange,提问作者ulandch
相关产品推荐
相关产品推荐

