So I googled around for the answer to this question and found a way to deploy just a react app to github pages using this medium article. The issue is my react app has a django back end. So github pages won't work. I also know how to deploy a django site to heroku. I also know you can deploy a react app to heroku. But deploying them separately makes them have different domains. Now is there a way to deploy a fullstack django and react app to heroku so both has same domain?
1 Answer
Things you could do:
Use subdomains for the two parts. e.g.
www.yourdomain.comfor the frontend andapi.yourdomain.comfor the backend. You could do this without changing your current hosting strategy, just by redirecting from the subdomains to the respective hostings.Host your react app on heroku as well and use the heroku domain services. This might need a small NodeJS wrapper for the react app to make it run but it's not too much effort
2 Comments
Cole
For the first option, I dont need a real custom domain as the project is a practice one, so imagine after hosting the django backend on heroku and get a domain 'yoursite.herokuapp.com', how do i add the frontend react part to it?
Linschlager
I don't think this is possible since you don't actually get access to your heroku domains. You'd need an actual top level domain with access to the dns records. For practice projects you could just get a free domain over on dot.tk