reactjs - 托管在 Heroku 上的 React 应用程序无法打开具有超过 1 个段的 URL 的页面
问题描述
我有一个在 Heroku 上托管的 React Web 应用程序 ( https://muzenda-frontend.herokuapp.com/ )。其他页面显示良好,但当 url 有超过 1 个段时,它只显示白屏。例如https://muzenda-frontend.herokuapp.com/ / 将显示一个空白的白色屏幕。一个实际的例子是https://muzenda-frontend.herokuapp.com/explore/data-scientist。
我的 package.json 包含以下内容
{
"name": "frontend",
"proxy": "http://127.0.0.1:5000",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.1.5",
"@emotion/styled": "^11.3.0",
"@material-ui/core": "^5.0.0-alpha.30",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"js-cookie": "^2.2.1",
"jwt-decode": "^3.1.2",
"material-ui": "^0.20.2",
"react": "^16.12.0",
"react-bootstrap-4-pagination": "^1.0.4",
"react-cookie-consent": "^6.2.3",
"react-dom": "^16.12.0",
"react-field-validator": "^0.2.2",
"react-infinite-scroll-component": "^6.1.0",
"react-inputs-validation": "^4.6.3",
"react-player": "^2.9.0",
"react-redux": "^7.1.3",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"serve": "^12.0.0"
},
"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"homepage": "."
}
这可能是什么原因造成的?
解决方案
推荐阅读
- angular - 角度:为什么值更改(使用渲染器2)不会触发绑定到该的事件
- typescript - 共享自定义 NestJS 模块给出“不是当前处理模块的一部分”错误
- python - 子类未在 Python 2.x 中初始化父类
- python - 直方图给出了概率密度函数的奇怪值
- java - 如何在日志文本上将 OrderId 显示为 Log4j 模式布局
- android - 改造 - 处理刷新令牌过期
- ios - 更改语义内容属性后 UI 挂起
- android - Android - 单元测试以检查光标是否已关闭
- python - 如何修复“由于 EnvironmentError:HTTPSConnectionPool 无法安装软件包”错误?
- ruby-on-rails - 如何在 ruby 和 ruby on rails 中只允许使用 preg_replace 的数字字符