Getting 404 on static resources in production #33751
-
Brand new to Next & React so forgive me ahead of time. I created a very basic app here: https://github.com/Entermedia-LLC/best-practices I'd like to deploy it using Github pages so did a static build using But when you visit it (https://entermedia-llc.github.io/best-practices/), missing all the static resources. But if you look at the repo, they are there. Example being getting a 404 on for https://entermedia-llc.github.io/best-practices/_next/static/css/fec0287c56dc29bf.css, but that file exists (and looks correct) in the repo: https://github.com/Entermedia-LLC/best-practices/blob/gh-pages/_next/static/css/fec0287c56dc29bf.css What's even weirder is when you try to visit that missing file directly: https://entermedia-llc.github.io/best-practices/_next/static/css/fec0287c56dc29bf.css, the output is a 404 page but also includes part of the app. Very strange because the file in the repo is pure CSS, not sure why it would be loading anything JS-wise. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Figured it out, had to with how Github pages work. Basically need to add a |
Beta Was this translation helpful? Give feedback.
-
For those who run "scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"export": "next export",
"deploy": "npm run build && npm run export && touch ./out/.nojekyll && gh-pages -d out -t true"
}, This will copy the .nojekyll file to the root folder and serve the static files. |
Beta Was this translation helpful? Give feedback.
-
On my case, I was putting many projects on github pages, |
Beta Was this translation helpful? Give feedback.
-
Figured it out, had to with how Github pages work. Basically need to add a .nojekyll file in the out folder to tell Git to serve the _next files. See https://stackoverflow.com/questions/61450307/js-and-css-not-loading-when-hosting-next-application-on-github-pages |
Beta Was this translation helpful? Give feedback.
Figured it out, had to with how Github pages work. Basically need to add a
.nojekyll
file in theout
folder to tell Git to serve the _next files. See https://stackoverflow.com/questions/61450307/js-and-css-not-loading-when-hosting-next-application-on-github-pages