【发布时间】:2022-10-12 21:44:13
【问题描述】:
试图在 firebase 上部署我的 react 应用程序。应用程序被部署,但是当点击链接时,它返回一个 404 页面。
我已经通过 cli 登录到 Firebase。使用firebase init:
? What do you want to use as your public directory? build
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? Set up automatic builds and deploys with GitHub? No
? File build/index.html already exists. Overwrite? No
使用npm start,应用程序运行完全正常,但是一旦我将npm run build 转换为firebase init 和firebase deploy,它会正确返回登录页面,但其他页面以 404 页的形式返回。
Firebase.json:
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
【问题讨论】:
标签: reactjs firebase firebase-hosting