djangoreactjsdjango-rest-frameworkwindows-server-2019

ReactJS API calls to Django REST - use IP or localhost?


I run a ReactJS front end application and Django REST back end/API both on the same webhost. The application works perfectly fine on localhost, however when you run it from somewhere else it can't seem to connect to the API.

Console of client's browser:

enter image description here

Django REST running on the server:

enter image description here

Am I supposed to connect to it using the external IP of the server instead of localhost? Localhost should work right, since both the frontend and Django API are hosted on the same server?


Solution

  • In case someone is looking for an answer, I've learned a few things since posting:

    Thanks to xxnora for giving me tips and steering me in the right direction.