【问题标题】:Deploy React app using create-react-app to github pages isn't working使用 create-react-app 将 React 应用程序部署到 github 页面不起作用
【发布时间】:2021-10-28 22:06:37
【问题描述】:

我设置了一个 github 操作,用于构建我的 react 应用程序并将构建目录提交到我的 repo 的 gh-pages 分支。然后我将 github 页面设置为为该分支提供服务,但我遇到了一个问题,我的所有静态文件都返回 404。

这是访问我的 github 页面站点时的控制台输出

Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'.
thatnerduknow.github.io/:1 GET https://thatnerduknow.github.io/static/css/2.0a9ec390.chunk.css net::ERR_ABORTED 404
thatnerduknow.github.io/:1 GET https://thatnerduknow.github.io/static/css/main.8e6a535e.chunk.css net::ERR_ABORTED 404
thatnerduknow.github.io/:1 GET https://thatnerduknow.github.io/static/js/main.6b85f889.chunk.js net::ERR_ABORTED 404
thatnerduknow.github.io/:1 GET https://thatnerduknow.github.io/static/js/2.e6086643.chunk.js net::ERR_ABORTED 404
thatnerduknow.github.io/:1 GET https://thatnerduknow.github.io/static/js/2.e6086643.chunk.js net::ERR_ABORTED 404
thatnerduknow.github.io/:1 GET https://thatnerduknow.github.io/static/js/main.6b85f889.chunk.js net::ERR_ABORTED 404
favicon.ico:1 GET https://thatnerduknow.github.io/favicon.ico 404
manifest.json:1 GET https://thatnerduknow.github.io/manifest.json 404
manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.

我的一个 vue 应用程序遇到了类似的问题,我必须将公共路径配置变量设置为“”,但在 package.json 中设置我的主页(我检查了 Create React App 文档,它说这就是它看起来将公共路径变量)设置为“”它仍然给我这个错误。

【问题讨论】:

  • 能否请您在 package.json 中设置"homepage":"thatnerduknow.github.io" 并尝试一下。
  • 这不起作用,但"https://thatnerduknow.github.io/ThatNerdUKnow/" 起作用了

标签: reactjs github-pages


【解决方案1】:

在 package.json 中更改主页路径

"homepage":"https://thatnerduknow.github.io/ThatNerdUKnow/"

【讨论】:

    猜你喜欢
    • 2017-07-21
    • 2017-11-03
    • 1970-01-01
    • 1970-01-01
    • 2020-10-21
    • 2018-08-21
    • 1970-01-01
    • 1970-01-01
    • 2017-03-17
    相关资源
    最近更新 更多