ARTICLE AD BOX
I am trying to submit a form using the fetch API in JavaScript, but I keep getting a 403 Forbidden error from the server.
Here is the code I am using:
fetch("https://example.com/api/submit", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name: "test", email: "[email protected]" }) }) .then(res => res.json()) .then(data => console.log(data)) .catch(err => console.error(err));Problem:
The request works fine in Postman
But in the browser, it always returns 403
No proper error message in response
What I have tried:
Checked API endpoint and headers
Disabled browser extensions
Tried different browsers
My question:
Why would the same POST request work in Postman but fail with a 403 error in the browser using fetch? Could this be related to CORS, authentication headers, or something else?
