nginx.conf 678 B

1234567891011121314151617181920212223
  1. # History 模式 SPA 回退:刷新 /mcp/guide、/mcp/online 等路由时返回 index.html
  2. # 使用方式:将 root 改为实际静态资源目录后,include 或复制到 Nginx 配置中
  3. server {
  4. listen 80;
  5. server_name _;
  6. # 改为构建产物目录,例如 /usr/share/nginx/html 或项目 dist 路径
  7. root /usr/share/nginx/html;
  8. index index.html;
  9. # 真实静态文件(js/css/图片)优先按文件返回,避免被回退成 HTML
  10. location /assets/ {
  11. try_files $uri =404;
  12. expires 7d;
  13. add_header Cache-Control "public";
  14. }
  15. # 前端路由:文件不存在时回退到 index.html
  16. location / {
  17. try_files $uri $uri/ /index.html;
  18. }
  19. }