vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.53k stars 27.05k forks source link

Deploy to github pages results in assets not found with Static HTML export #15588

Closed glenngijsberts closed 4 years ago

glenngijsberts commented 4 years ago

Bug report

Describe the bug

I would like to host a project on github pages but the static html export (generating the /out directory) doesn't seem to work for me when I add an assetPrefix. Somehow the assets can't be found. In my network tab the path's of the files seem to match my domain but somehow they end up with a 404 error, see To Reproduce.

I've tried to find more info at the docs but I probably miss some config. When I searched for any docs/guides for deploying to github pages I came across this link but that one doesn't seem to work anymore.

The main problem now is that my JavaScript interaction is not working (for example searching for an icon).

To Reproduce

  1. Go to https://ticketswap.github.io/comets-playground/
  2. Open devtools and open network tab
  3. Refresh and see all the 404 codes.
Screenshot 2020-07-28 at 18 12 46

Source code Deployed code Raw index.html

next.config.js

module.exports = {
  exportPathMap: function () {
    return {
      '/': { page: '/' },
    }
  },
  assetPrefix: '/comets-playground/',
}

Expected behavior

No mismatch from index.html with the assets and working javascript interactions.

System information

Additional context

Not sure what to provide anymore but let me know if you need any info :)

imdongchen commented 4 years ago

Try adding .nojekyll under gh-pages branch. See https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/

glenngijsberts commented 4 years ago

@imdongchen Thanks for your reply! That fixed it indeed. Awesome!

balazsorban44 commented 2 years ago

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.