I have a small project with create-react-app, which I wanted to host on github pages. It would be:
stopachka.github.io/my-project
The help in our tutorial was awesome. However, when loading the project, assets are not correctly found.
In the generated index.html, we have ->
<script type="text/javascript" src="/static/js/main.ce66e420.js"></script>
This will direct github-pages too
https://stopachka.github.io/static/js/main.ce66e420.js
which return a 400. It should instead direct to ->
stopachka.github.io/my-project/static/js/main.ce66e420.js
Ideas:
/
prepended to it. I think the tutorial you linked to mentions the fix in the first sentence 馃槈 .
Open your
package.json
and add ahomepage
field:"homepage": "http://myusername.github.io/my-app",
If you do this, Create React App will know to use /my-app
as root URL.
Clarified in the doc: 6aabe7e881f45fd52e8481bbe2463ea3fce8c1ba.
The most recent version also explains this behavior after build:
Ah, nice, thanks for the clarification @gaearon -- initially thought it was just meant as a flag to output the instructions. Super nice touch :)
Most helpful comment
I think the tutorial you linked to mentions the fix in the first sentence 馃槈 .
If you do this, Create React App will know to use
/my-app
as root URL.