I'm hosting my exported static page on gh-pages with a custom domain.
Error shown is as follows:
The script from “http://___.co/_next/static/runtime/webpack-f5e50b6b501ccea2a79b.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
Loading failed for the <script> with source “http://___.co/_next/static/runtime/webpack-f5e50b6b501ccea2a79b.js”.
Images are loaded fine. It's only hashed files which don't work.
Export and push to gh-pages.
Site renders properly and loads all assets as it should.
I'm guessing it's related to this note? https://github.com/zeit/next.js/wiki/Deploying-a-Next.js-app-into-GitHub-Pages#extra-step-for-project-page-sites
This doesn't sound like a particular bug with Next.js, more-so hosting configuration side. Might be interesting to look into hosting on https://zeit.co.
I don't think it is related to the assetPrefix because I'm using a custom domain. Should be under /_next then, no?
It could be a problem on the host. But if gh-pages is part of the documentation, it should work, shouldn't it?
@leon-wbr have you solve it?
I've got the same problem. You can check it under:
https://mariowski.pl/ (check console) & https://github.com/Xandev/my-website/
If you are having a similar problem and found this issue, here is what solved my problem.
Had a similar problem, on my case it was the .nojekyll file missing. I tried fixing adding it right after generating the static assets:
"scripts": {
...
"static": "next build && next export && touch ./out/.nojekyll && echo 'evandro.sasse.it' > ./out/CNAME",
...
},
The link @timneutkens posted doesnt work anymore, but you can find more information on this issue: https://github.com/zeit/next.js/issues/2029.
BUT...
I am also using gh-pages to send the files from the out folder to the branch Github Pages will serve, by default the .nojekyll file was not being saved there. You can use the option -t true to circumvent this behaviour. More info on this issue https://github.com/tschaub/gh-pages/issues/315. My deploy script looks like this now:
"scripts": {
...
"deploy": "gh-pages -d out -t true"
...
},
Most helpful comment
If you are having a similar problem and found this issue, here is what solved my problem.
Had a similar problem, on my case it was the
.nojekyllfile missing. I tried fixing adding it right after generating the static assets:The link @timneutkens posted doesnt work anymore, but you can find more information on this issue: https://github.com/zeit/next.js/issues/2029.
BUT...
I am also using
gh-pagesto send the files from theoutfolder to the branch Github Pages will serve, by default the.nojekyllfile was not being saved there. You can use the option-t trueto circumvent this behaviour. More info on this issue https://github.com/tschaub/gh-pages/issues/315. My deploy script looks like this now: