Hosting React-App on gh-pages / godaddy

Hello.

I’ve built my react-app using create-react-app and made a seperate branch using gh-pages.
The app worked as intended using default URL of ronnehag.github.io/react-portfolio.

Repository is here

I bought a .com domain from godaddy and changed service to CloudFlare.

I managed the DNS as following,

Points to:
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
CNAME www ronnehag.github.io

I then added the domain fredrikronnehag.com in the gh-pages branch settings, which created the CNAME file with that domain.

However, browsing to that address only results in a blank page with the correct page-title.
I tried removing the CNAME and put it in the master-branch, that defaulted in the .com address leading to the readme.md, so the routing seems to work there.

In my package.json I added the following lines,

"homepage": "http://ronnehag.github.io/react-portfolio"
"scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",

And built the app through yarn deploy.

Any suggestions?

1 Like

Hi Fredrik

The url (https://fredrikronnehag.com/) works for me, screenshot below.

Assuming you managed to find a solution? If not, it might be something as simple as a dns cache in your browser stopping you seeing it correctly. Try clearing that.

Your site looks great btw :+1:

Hope that helps :slight_smile:

Yes, it’s working now.
I had to change the “homepage” in package.json to “http://www.fredrikronnehag.com/”,
as well as readjusting the routes for the router to match that url.
Thought the homepage was where the files were hosted, not to the custom domain.

Thank you! :slight_smile:

Hey Ronnehag,

Just wanna say thank you for your post, I’ve been trying to figure this out for a night until stumbling upon your post. It finally works!

What works for me is:

change the “homepage” in package.json to
http://www.[my-website].com/

Go Daddy -
Points to:
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
CNAME www [my-username].github.io

And the one last KEY is
under my github repo/ setting/ github page,
I change the “custom domain” from
[my-website].com
to
www.[my-website].com

Although
[my-website].com
will forward users to
www.[my-website].com
but I still need to put the second url with the www in the “custom domain” for github page to work

It sounds stupid, but it finally works!