Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
what is Cors-Policy why it is not allowing me to use content- type in post request of Fecth API in javascript?

it is showing like this when i am running the post request in console

Access to fetch at 'http://dummy.restapiexample.com/api/v1/create' from origin 'http://127.0.0.1:5501' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
tut42.js:57 POST http://dummy.restapiexample.com/api/v1/create net::ERR_FAILED
postData @ tut42.js:57
(anonymous) @ tut42.js:61
tut42.js:57   Uncaught (in promise) TypeError: Failed to fetch
    at postData (tut42.js:57)
    at tut42.js:61
postData @ tut42.js:57
(anonymous) @ tut42.js:61
Promise.then (async)
postData @ tut42.js:58
(anonymous) @ tut42.js:61
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Being a cross domain request the API call seems to be blocked itself can you try adding Access-Control-Allow-Headers individually or you can switch to no-cors mode.

fetch(request, {mode: 'cors'});

For better understanding for CORS kindly check https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS.

And for the different header that you can play in correspondence with Access-Control-Allow-Headers is in the following link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers

Access-Control-Allow-Headers: *
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!