I'm using npm json-server
from here. It used to work great for my needs: run a server on my PC and do GET
requests to local IP (192.168.1.XX). I reinstalled it and now I can do requests only to localhost or 127.0.0.1. Can't do requests to local IP (cmd ipconfig) anymore. I'm getting this error:
As @fvu mentioned here
this means that the server software is configured to listen on the localhost interface only. This is a configuration item and to avoid exposing a potentially unsecure server many server programs come preconfigured to listen on localhost only.
So is there a way to access this server via local IP as long as json-server doesn't have some extra parameters to enable/disable it?
We just need to use the --port number flag. For example: json-server --watch db. json --port 3004.
json , you can change the port inside the lite-server module. Go to node_modules/lite-server/lib/config-defaults. js in your project, then add the port in "modules. export" like this.
I found the solution for this issue:
json-server --host 192.168.1.XXX my_file.json
Using this command, server is deployed on my local IP, and Windows asks for a firewall exception.
Another solution is to switch to .NET server - another free simple fake server where I can setup local IP as endpoint.
All it needs to:
use CMD commands:
git clone https://github.com/ttu/dotnet-fake-json-server.git cd dotnet-fake-json-server/FakeServer dotnet run [--file] [--urls] #like so in my case: dotnet run --file_data.json --urls http://192.168.1.192:57602
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With