4

I'm not sure what I'm doing wrong. i've followed all the steps to set up a custom domain name, but maybe I'm missing something.

I followed the steps in this article so my settings look like this:

A Record @ 192.30.252.153 Automatic
A Record @ 192.30.252.154 Automatic
CNAME Record www myusername.github.io. Automatic

I added a CNAME file which only has my domain name in it.

I added the CNAME file to the public folder of my react app as the instructions here state.

I went to my github settings and set the domain name. It currently has a checkmark saying that my site has been published.

Going to my site here gives a 404 error. What else am I supposed to do?

2 Answers 2

6

I had a similar issue when trying to set a custom domain with create-react-app on a github project page.

An easy solution worked for me is:

  1. Add a "CNAME" file in the "public" folder with only the domain in this file(start with "www" without "https://");

  2. Change the homepage in the "package.json" file from "https://xxx.github.io/xxx" to your domain that you put in the "CNAME" file with "https://";

  3. In Git Bash, follow the basic steps 'git add .', 'git commit -m "change"', 'git push origin master' to update the changes;

  4. In Git Bash still, run "npm run deploy", then type the domain in your browser (clear previous history), it should show up the lovely "welcome to React" page.

Regards,

Sign up to request clarification or add additional context in comments.

Comments

1

It is definitely not giving a 404. It seems some of the links to your loaded js/css files are malformed, but the index.html is loading just fine.

You should keep in mind that your ISP and your computer both try to cache information about where a given domain name should route to. This can sometimes mean that the path to the destination IP is cached and will show you the out of date resource immediately after a new CNAME is added.

Most ISPs guarantee a refresh of the related cache within 48 hours. If you need to check faster than that, I would try to find a different internet connection and device to use to access the page after you have everything set up. Smart Phones are invaluable for this, just make sure the wifi is turned off.

3 Comments

It was giving a 404 earlier. Now it's just a blank page. So I should just wait for changes? This is my first time dealing with a custom domains.
The blank page is because your imports are malformed. Open up the dev-tools panel (right-click and click inspect, or CTRL-SHIFT-I in chrome), and then navigate to the "Network" tab. Refresh the page and you will see what files your index is trying to import. Those files are getting 404 errors. We know that these 404's are not a result of the CNAME (because the index.html loaded), so it must mean that the file name and/or path is incorrect.
I see. Thank you for the help. I checked my package.json and saw it was deploying to my old github pages site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.