惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
D
Docker
C
Cyber Attacks, Cyber Crime and Cyber Security
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
The Hacker News
The Hacker News
Project Zero
Project Zero
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
V
Visual Studio Blog
The GitHub Blog
The GitHub Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Scott Helme
Scott Helme
A
About on SuperTechFans
WordPress大学
WordPress大学
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
G
GRAHAM CLULEY
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Schneier on Security

问题库 on 打工人日志

k8s master 节点 Unauthorized kindle 邮件发送失败,错误代码E999 SELinux 问题:导致端口无法创建,无法访问 linux服务器进程打开文件过多导致服务异常 解决Elasticsearch索引只读(read-only) Linux 系统收包流程以及内核参数优化 githubAction set-output弃用错误 k8s CNI 问题 连接认证失效 k8s.gcr.io国内无法连接解决方法 K8S 问题排查:cgroup 内存泄露问题 docker 问题处理 安装 docker 出现 ERROR: Unsupported distribution 'ol' 问题
Vue3 + vite + nginx项目部署后404问题
作者 · 2023-08-10 · via 问题库 on 打工人日志

Vue3 + vite + nginx项目部署后404问题

vue3 + vite + nginx
在服务器上部署后打开首页都没问题,打开其他路径全部 404。
nginx 报错日志:No such file or directory

其实查看 build 后的dist文件夹可以发现,只有一个index.html,当你访问别的路径时nignx查找不到所以就报错了

解决方案

在 nginx.conf 中添加: try_files $uri $uri/ /index.html;

server {
          listen       80;
          server_name  localhost;
          location / {
          root   /dist;
          index  index.html index.htm;
          # 在配置文件的此处加上这句话
          try_files $uri $uri/ /index.html;
        }
    }

总结

其实上述改动就是告诉 nignx 找不到文件的时候就访问 index.html 就可以了。

究其原因其实就是是 vue3 的 router 使用了history模式,该模式与之前hash模式的具体区别可以自行百度一下,不在此赘述。