datamllab / rlcard-showdown

Leaderboard and Visualization for RLCard
357 stars 98 forks source link

cannot interact with django server when scripts are run in a remote server #10

Closed dennislx closed 3 years ago

dennislx commented 3 years ago

Hi, I have run the following on my local computer to start a remote service:

python manage.py runserver 0.0.0.0:8000

I can visit remote_ip:8000 this way. However it shows a blank table with no records read from the database (i.e., db.sqlite3) after I type npm start. Things went perfectly fine when I serve both on my local computer (even a remote frontend and local backend combination could work).

I wonder what configurations should be done to deal with it. Thanks for your work.

hsywhu commented 3 years ago

Hi @dennislblog , please try change the apiUrl under /src/utils/config.js from http://127.0.0.1:8000 to http://remote_ip:8000

This is because the frontend sends API requests from the browser that you open up webpage rather than from the machine where you start the service. So no matter where you start the frontend service, by default it would only fetch table data from the same local network with the machine where you open up the page.

dennislx commented 3 years ago

Hi @dennislblog , please try change the apiUrl under /src/utils/config.js from http://127.0.0.1:8000 to http://remote_ip:8000

This is because the frontend sends API requests from the browser that you open up webpage rather than from the machine where you start the service. So no matter where you start the frontend service, by default it would only fetch table data from the same local network with the machine where you open up the page.

Thanks. Problem is solved. Simply follow what you said: 1) change apiUrl to my remote ip; 2) allow all-binding ips when starting the backend service.

// src/utils/config.js
const apiUrl = 'http://my-remote-ip:8000';

now things get work.

cd server && python manage.py runserver 0.0.0.0:8000
npm start