简体   繁体   中英

ReactJS app deployed on GitHub pages does not work with custom domain set

App works perfectly fine when it's deployed on https://github.io/architect_portfolio (when custom domain is not set). When it's deployed to https://architect.mszanowski.pl , all I can see is a blank white page.

在此处输入图片说明 在此处输入图片说明

What can I do to make it working? I think it has something to do with architect_portfolio part in assets urls.

To deploy it on custom domain I did following:

  1. add CNAME mszan.github.io. record to my architect.mszanowski.pl subdomain,
  2. update my package.json homepage and name values:
  "homepage": "https://architect.mszanowski.pl",
  "name": "architect_portfolio",
  1. made a commit to master branch,
  2. run gh-pages -d build

Repo: https://github.com/mszan/architect_portfolio

Another repo of working React app deployed on custom domain which is working fine: https://github.com/mszan/aestral_portfolio

Your second repo that works fine have CNAME file in gh-pages branch which contains the custom domain who github reads for custom domains mapping. While the repo that does not work in your case don't have this file in your gh-pages branch.

Solution:

Add CNAME file to /public dir

For details please consult getting-a-custom-domain-to-behave-with-react-on-github-pages .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM