GithubHelp home page GithubHelp logo

ngduc / api-now Goto Github PK

View Code? Open in Web Editor NEW
109.0 109.0 6.0 4 MB

$ api-now - Launch an API Server to serve a JSON, JS file, GraphQL or faker data with HTTPS support.

License: MIT License

JavaScript 99.75% HTML 0.25%
api https https-server json json-server mock mock-server server

api-now's Introduction

ngduc's GitHub stats

api-now's People

Contributors

ngduc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

api-now's Issues

All non-GET requests return 403 Forbidden when using https

All non-GET requests return 403 Forbidden when using https

  • bug: I'm working with HTTPS. I can read the db.json just fine with GET requests. But all POST, PUT, PATCH, etc. requests to write to the file return 403 Forbidden.

Environment Details

  • api-now version: 0.5.4
  • OS: Windows 10
  • Node.js version: 16.13.2

Long Description
I'm working with HTTPS. I can read the db.json just fine with GET requests. But all POST, PUT, PATCH, etc. requests to write to the file return 403 Forbidden. The following screenshot is from the Fiddler tool. The same thing is seen in the console of the F12 tools.

image

This screenshot is of the server window:

image

const getData = () => { 
  fetch('https://localhost:3001/posts/1')           //api for the get request
  .then(response => response.json())
  .then(data => console.log(data));
};

const newPost =  {
  "id": 2,
  "title": "json-server",
  "author": "Rick"
}
// Options to be given as parameter
// in fetch for making requests
// other then GET
let options = {
	method: 'PUT',
	headers: {
		'Content-Type':	'application/json;charset=utf-8'
	},
	body: JSON.stringify(newPost)
}

const setData = () => { 
  fetch('https://localhost:3001/posts/1', options)           //api for the set request
  .then(response => response.json())
  .then(data => console.log(data));
};

Workaround

none
...

(Please help with a PR if you have a solution. Thanks!)

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.