angular - firebase托管后下拉链接不起作用
问题描述
我正在关注 Udemy 的角度教程。我可以在本地主机中打开引导导航栏下拉链接,但在托管到 firebase 后无法打开(其他导航栏链接按预期工作)。请帮忙
我在 404 错误之后降落在他身上:
404 Page Not Found 在这个网站上找不到指定的文件。请检查 URL 是否有错误,然后重试。为什么我会看到这个?此页面由 Firebase 命令行界面生成。要修改它,请编辑项目配置的公共目录中的 404.html 文件。
索引.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Oshop</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.ffb6f1d88864b80c037e.css"></head>
<body>
<app-root></app-root>
<script type="text/javascript" src="runtime.a66f828dca56eeb90e02.js"></script><script type="text/javascript" src="polyfills.2f4a59095805af02bd79.js"></script><script type="text/javascript" src="main.10b7c76792e4769182f0.js"></script></body>
</html>
firebase.json:
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
解决方案
我通过将我的 firebase.json 文件修改为以下内容来修复它:
"rewrites": [{
"source": "/public/**",
"destination": "/public.html"
},
{
"source": "**",
"destination": "/index.html"
}]
推荐阅读
- c - 动态链接和全局变量
- java - ObjectInputStream - 读取对象 - 有没有办法阻止调用无参数超类构造函数?
- javascript - 使用模式构建的突变中的对象数组 - Graphql - 问题
- c - 整数溢出与 C 中的乘法
- html - 使用 CSS 在两列之一中居中图像
- c - Codelite 无法正确下载?
- excel - 在页面的最后一行之后直接打印页脚
- html - 将 2 个元素(倒数计时器和按钮)并排放置在行中 - 它们不居中
- nginx - 安装在 nginx 上的 lucee 服务器的问题
- javascript - 如果从另一个模块调用该模块,为什么改变一个模块会更新引用,但如果从自身调用则不会?