I've been working on a project using Django as backend and React as a framework for the frontend. I've deployed this project in Pythonanywhere and it worked fine. Now, I would like to implement Next.js in my project but, unfortunately, Pythonanywhere does not support Node.js. So I decided to deploy my frontend in Vercel and let the backend in Pythonanywhere.
To achieve this, I plan to create a subdomain that handles the API request. In the domain DNS panel, each domain and subdomain respectively will point to different sites. It'd look like this:
I've searched about this in Google and it should work. But, here comes my question, is this the best approach or should I consider other options?
Here is a post that is related to this one. In the post, the author plans to deploy both: backend and frontend on GCP.
Thank you in advance for your time and answers!
The setup you described is pretty standard and it will work perfectly. All you need is to take care of the following points:
76.76.21.21 in the root domain and a CNAME record to cname.vercel-dns.com on the "www" subdomain. Remember to redirect the domains for optimal SEO score.api.example.com should point to the other provider. You need to check if they require an A or CNAME record. They may require additional DNS records (CAA?).example.com should trigger requests to api.example.com. Your CORS configuration should account for that. CORS is a whole different discussion but I will point you in the right direction. You need to check Next.js custom headers and CORS guides.If you face any issues on Vercel, you can contact their support channel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With