Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets not loading on GitHub Pages with Custom Domain #8316

Closed
leon-wbr opened this issue Aug 10, 2019 · 5 comments
Closed

Assets not loading on GitHub Pages with Custom Domain #8316

leon-wbr opened this issue Aug 10, 2019 · 5 comments

Comments

@leon-wbr
Copy link

Bug report

Describe the bug

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.

To Reproduce

Export and push to gh-pages.

Expected behavior

Site renders properly and loads all assets as it should.

System information

  • gh-pages
  • Ubuntu
  • .nojekyll and CNAME added.
@timneutkens
Copy link
Member

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.

@leon-wbr
Copy link
Author

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?

@RMariowski
Copy link

RMariowski commented Jan 4, 2020

@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/

@evsasse
Copy link

evsasse commented May 17, 2020

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: #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 tschaub/gh-pages#315. My deploy script looks like this now:

  "scripts": {
    ...
    "deploy": "gh-pages -d out -t true"
    ...
  },

sony-mathew added a commit to sony-mathew/sony-mathew.github.io that referenced this issue Oct 2, 2020
GH pages was having some issue in serving assets. So added the
.nojekyll file to fix this as per
vercel/next.js#8316
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants