As in the title I use React.js at the frontend and Django at the backend. I basically remade a website for my father's enterprise and we got cPanel on our hosting service (prevoius website was made in Django alone). The problem is I use cross origin in the new app. It is easy for me to just open up 2 command prompts and start 2 different localhosts for Django and React, but I have no idea how to do it on the server side.
I had some ideas before like: "Should I buy a second server and host just React there?" or "Should I somehow merge backend and frontend together?", but still I have no idea which solution would fit the most.
I would be grateful for any advice, tutorials, links that would help me solve this problem. If needed I can paste a github link to a project aswell.
You have to set the Access-Control-Allow-Origin header in your server config:
The Access-Control-Allow-Origin header specifies which URLs are allowed to be accessed by JavaScript:
For example:
Access-Control-Allow-Origin: http://www.example.com
would allow your App to access www.example.com