我正在尝试将所有URL重定向到我的SPA的index.html。当firebase.json是一个目录深度(例如http://localhost:8000/page1 )而不是更深(例如http://localhost:8000/covid19-dashboard/page1/page1a无法加载并给出控制台错误Uncaught SyntaxError: Unexpected token '<' )时,我的下面的URL可以工作。我也尝试了下面的方法,但是用"source": "**/**"也发现了同样的结果。
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "dist",
"target": "project-name",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"storage": {
"rules": "storage.rules"
}
}发布于 2020-04-15 00:40:14
这只是一个猜测,但请检查您的<script>标记,看看它们是否是相对URL(例如,<script src="js/main.js">。您需要将它们设置为绝对的(例如<script src="/js/main.js">),以便当更深层次的链接的相对路径发生变化时,它们能够正确加载。
您看到的错误很可能是因为脚本加载的.js文件不存在,因此加载了您的index.html。
https://stackoverflow.com/questions/61211734
复制相似问题