Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All non-GET requests return 403 Forbidden when using https #8

Open
Rick-Kirkham opened this issue May 10, 2023 · 3 comments
Open

All non-GET requests return 403 Forbidden when using https #8

Rick-Kirkham opened this issue May 10, 2023 · 3 comments

Comments

@Rick-Kirkham
Copy link

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!)

@left0ver
Copy link

metoo

@Rick-Kirkham
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Rick-Kirkham @left0ver and others