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.
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!)
metoo
UPDATE: It really has nothing to do with HTTPS. It happens with HTTP too. The problem is that the server needs to set CORS headers and the documentation doesn't say how to do that.