ant design pro 项目发布遇到登录页访问404

在发布ant design pro 项目之后,访问登录页404.

nginx配置如下

javascript 复制代码
server {
    listen       80;
    listen  [::]:80;
    server_name  cargo.*****.cn;

    location / {
        root   /usr/share/nginx/html/cargo/dist;
        index  index.html index.htm;
    }

    location /api {
        proxy_pass http://*.**.*.*:9008/api;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

解决方案一

项目config.ts配置文件中增加如下配置

javascript 复制代码
  history: {
    type: 'hash'
  },

解决方案二

修改nginx配置如下

javascript 复制代码
server {
    listen       80;
    listen  [::]:80;
    server_name  cargo.*****.cn;

	root   /usr/share/nginx/html/cargo/dist;

    location / {
        try_files $uri $uri/index.html /index.html;
    }

    location /api {
        proxy_pass http://*.**.*.*:9008/api;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

参考资料

AntDesign Pro 构建部署后无法登录 Response status:404

相关推荐
sunfove3 小时前
光网络的立交桥:光开关 (Optical Switch) 原理与主流技术解析
网络
HIT_Weston3 小时前
93、【Ubuntu】【Hugo】搭建私人博客:面包屑(一)
linux·运维·ubuntu
cuijiecheng20183 小时前
Linux下Beyond Compare过期
linux·运维·服务器
喵叔哟4 小时前
20.部署与运维
运维·docker·容器·.net
HIT_Weston4 小时前
92、【Ubuntu】【Hugo】搭建私人博客:侧边导航栏(六)
linux·运维·ubuntu
CodeAllen嵌入式4 小时前
Windows 11 本地安装 WSL 支持 Ubuntu 24.04 完整指南
linux·运维·ubuntu
期待のcode4 小时前
前后端分离项目 Springboot+vue 在云服务器上的部署
服务器·vue.js·spring boot
AI 智能服务4 小时前
第6课__本地工具调用(文件操作)
服务器·人工智能·windows·php
Kevin Wang7275 小时前
欧拉系统服务部署注意事项
网络·windows
min1811234565 小时前
深度伪造内容的检测与溯源技术
大数据·网络·人工智能