I am trying to access node js api which works on host/localhost machine. While accessing from other devices using ngrok or IPv4 link it shows UI of the website correctly but the API doesn't works functionally(e.g. user login). By clicking Login button in vscode API terminal doesn't get any request which is called successfully from localhost machine. How do I solve this issue to work functionally from other devices too?
Asked
Active
Viewed 150 times
-1
-
Did you got 403 or 405 not allowed error ? – boolfalse Mar 29 '21 at 13:42
-
no error code is there – Sudhir S Pawar Mar 29 '21 at 13:43
-
Nodejs api url is http://127.0.0.1:5000/api which is doesnt accessible from external computers what should I do to access it from external computers – Sudhir S Pawar Mar 31 '21 at 14:42
1 Answers
0
If you're using ngrok for this you may need another tunnel for the API, unless both the UI and API are served from 127.0.0.1:5000
.
If they are served from the same service port then your single ngrok tunnel should work for HTTP transport to both. You would either need to alter your API calls so that the hostname is your tunnel's hostname, or you could just make your API calls with relative URLs. For example the API could make a request to /api/resource
rather than 127.0.0.1:5000/api/resource
.

Andrew Benton
- 73
- 5