json-server cannot access via local IP

前端 未结 5 1090
盖世英雄少女心
盖世英雄少女心 2020-12-13 20:31

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 r

5条回答
  •  一个人的身影
    2020-12-13 20:56

    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:

    1. install .NET
    2. 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
      

提交回复
热议问题