简体   繁体   English

使用 create-react-app 将 React 应用程序部署到 github 页面不起作用

[英]Deploy React app using create-react-app to github pages isn't working

I have a github action set up that builds my react app and commits the build directory to the gh-pages branch of my repo.我设置了一个 github 操作来构建我的 React 应用程序并将构建目录提交到我的 repo 的 gh-pages 分支。 I then set github pages to serve that branch but i'm getting a problem where all of my static files are returning 404.然后我设置 github 页面来为该分支提供服务,但我遇到了一个问题,我的所有静态文件都返回 404。

here's my console output when visiting my github pages site这是访问我的 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.

I've had a similar problem with one of my vue applications where I had to set the public path config varialbe to "" but setting my homepage in package.json (I checked the Create React App documentation and it says that's where it looks to set the public path variable) to "" it still gives me this error.我的一个 vue 应用程序也遇到了类似的问题,我必须将公共路径配置变量设置为“”,但在 package.json 中设置我的主页(我查看了 Create React App 文档,它说这就是它查找的位置将公共路径变量) 设置为 "" 它仍然给我这个错误。

在 package.json 中更改主页路径

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在 Github 页面上部署新的 create-react-app - Cannot deploy fresh create-react-app on Github Pages 无法将 create-react-app 部署到 github-pages - cannot deploy create-react-app to github-pages 将create-react-app应用程序部署到github页面可以很好地构建,但是不会部署 - deploying create-react-app app to github pages builds fine but won't deploy 使用github页面的create-react-app的自定义域 - Custom domain using create-react-app for github pages 用于create-react-app的ES6 Polyfill不起作用 - ES6 Polyfill for create-react-app isn't working 如何将 create-react-app 部署到 github 页面? 收到“致命:无法从远程存储库读取”。 - How to deploy create-react-app to github pages? getting "fatal: Could not read from remote repository." 由 create-react-app 制作的 React 页面不适用于 IE。 babel 没有用吗? - React pages that is made by create-react-app don't work on IE. Isn't babel useful? 在Github Pages上更改为自定义域会导致带有react-router的create-react-app停止工作 - Changing to custom domain on Github Pages causes create-react-app with react-router to stop working 无法在 Github 页面上部署 React 应用程序 - Can't deploy react app on Github pages 如何使用 create-react-app 部署 React 应用程序 - How to deploy a react app using create-react-app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM