Ad

Problem With Deploy React App With Gh-pages

- 1 answer

I've got a problem with deploying my react app with gh-pages. I tried all guides from YT and those from the first site of Google. And my GitHub pages don't show an app still. link to my repo: https://github.com/maksymilianMroz/react-todo-app

the question is Where is the problem? I didnt write smth in the code? How can I fix this? (I want to live preview on my react app by ghpages)

Ad

Answer

When you open your project site https://maksymilianmroz.github.io/react-todo-app/ and do a full refresh with the developer tools of your browser enabled, you will see that all javascript and css references result in a 404. This is because all url all prefixed with maksymilianMroz.

eg https://maksymilianmroz.github.io/maksymilianMroz/react-todo-app/static/css/main.fbf7fb8c.chunk.css

where it should be https://maksymilianmroz.github.io/react-todo-app/static/css/main.fbf7fb8c.chunk.css

This is caused by the homepage property of your package.json file, as shown in the output of npm run build

enter image description here

If you adjust that property in the package.json your build will be fine.

{
  "name": "react-todo-app",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://maksymilianMroz.github.io/react-todo-app",
  ...
}
Ad
source: stackoverflow.com
Ad