简体   繁体   中英

Calling local api on a server from a hosted website

I'm currently hosting a website and I'm trying to call an API on a remote server. This remote server has a website running locally, and I'm trying to call a certain API from my website to the remote server's localhost. Is something like this possible, or would I have to host the website on the remote server so it isn't locally hosted.

For instance, would something like http://IP_address_of_server_goes_here:8000/get_matching_data/?XXXX be possible to get some data from this localhost?

If you have a computer that is running a server with an API locally, you can only access it with the same computer and other computers on the same network. You have a few options:

Connecting on the same wifi

IF your client (connecting) device is on the same wireless network as the server, you can often access the server by using http://12.0.0.1:8000/whatever . There are plenty of resources for learning how to do this as it can be a tricky process. It looks like it may be slightly different for Django, check out this question: django accessing localhost from any machine connected to any network

Connecting from anywhere with localhost tunneling

If you would like to connect to your server to test without being restricted by the localhost, you can take a look at providers such as ngrok or pagekite . Essentially, localhost tunneling is miniature hosting. These providers give you limited access to using their subdomains for remote testing. DO NOT use this as a production solution, as they are not secure or very stable.

Host it

Check out heroku for free, easy hosting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM