getting 404 for links with create-react-app deployed to github pages

前端 未结 2 670
旧巷少年郎
旧巷少年郎 2020-12-03 02:08

I\'m trying to deploy a create-react-app to a relative path on GitHub pages with a custom domain. E.g. www.example.com/myproject

I\'m using react-

2条回答
  •  失恋的感觉
    2020-12-03 02:21

    The reason is because the browser may not have cached the routing code yet so it causes a 404 error if you go to a route other than the index.

    Side note if anyone is using ZEIT Now to deploy (although gh-pages would be similar); I managed (after a deal of time) to work out how to fix it. It was a bit of an effort so I decided to make an article on it for anyone else who gets stuck.

    https://itnext.io/fix-404-error-on-single-page-app-with-zeit-now-b35b8c9eb8fb

提交回复
热议问题