GithubHelp home page GithubHelp logo

ajoelp / mock-json-server Goto Github PK

View Code? Open in Web Editor NEW
31.0 3.0 8.0 869 KB

A mock web server using a JSON file with live-reload support.

License: MIT License

JavaScript 72.17% HTML 11.51% Dockerfile 1.71% Shell 8.77% HCL 5.85%
mock-server json node javascript http http-server live-reload

mock-json-server's Issues

Allow api path to be dynamic from the index page

On the index page line 17 localhost is hardcoded and if you need to host on a domain domain.com the references to the API's still points to localhost

When hosting from domain.com the links to the API's should reference the hosting domain as a base path to the API calls.

Screenshot 2019-09-17 at 20 41 22

[feature request] Handle ? and & in url

Is it possible to add support for different router to support queering like:
api would output something else than api?id=1 and something else for api?id=1&user=test

Currently there api?id=1 fall into api But I cannot force it to different output.

Vulnerability: Listens on host 0.0.0.0 by default (but logs "localhost" to stdout)

Describe the bug

To Reproduce
Steps to reproduce the behavior:

  1. npm install mock-json-server
  2. Create api.json
  3. mock-json-server ./api.json --port 8080

Expected behavior

  • Listen only on localhost/127.0.0.1 by default
  • Log bound host depending argument passed to app.listen(...)

Desktop:

  • OS: Windows 10
  • NodeJS 10.15.0
  • Version 1.3.2

Additional context
Uses

server = app.listen(port, function() {
    callback();
});

in src/server/index.js to start server, however NodeJS uses host 0.0.0.0 as default (not 127.0.0.1), see https://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback

Cors access denied on same machine

Hi,

Do you know how can we configure mock-json-server to support same machine requests?

Currently I ran mock-json-server on port 3000
and angular app on port 8000

I get this error:

angular.js:13531 Access to XMLHttpRequest at 'localhost:3000/sample' from origin 'http://localhost:8000' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

when calling:
$http.get('http://rest-service.guides.spring.io/greeting')

is mock-json-server configurable to disable CORS policy?

Server returned HTML instead of JSON

Describe the bug
I installed and rand mock-json-server as described in the documentation. However, when I access http://127.0.0.1:8000/, I got some HTML instead of JSON: https://gist.github.com/MCakrt/726803cb6e86f535456a437f32710a68
Furthermore http://127.0.0.1:8000/home does not work, I get "Cannot GET /home"

Expected behavior
I expected mock-json-server to return the JSON file I provided.

Desktop:

  • OS: Windows 10 OS Version 2009 (Build 19042.746)
  • Google Chrome | 88.0.4324.146 (Official Build) (64-bit) (cohort: Stable)
  • node.js version 14.15.4
  • npm version 6.14.10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.