ngduc / api-now Goto Github PK
View Code? Open in Web Editor NEW$ api-now - Launch an API Server to serve a JSON, JS file, GraphQL or faker data with HTTPS support.
License: MIT License
$ api-now - Launch an API Server to serve a JSON, JS file, GraphQL or faker data with HTTPS support.
License: MIT License
All non-GET requests return 403 Forbidden when using https
Environment Details
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.
This screenshot is of the server window:
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!)
Please help me simulate HTTP response code like json-server.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.