₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,346,627 members, 8,524,250 topics. Date: Tuesday, 24 November 2026 at 03:53 PM

Toggle theme

Backend Devs Please Help Me With A Cors Error - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Backend Devs Please Help Me With A Cors Error (915 Views)

1 Reply (Go Down)

Backend Devs Please Help Me With A Cors Error by Tobedated(op): 5:08am On Dec 18, 2022
I'm trying to make a post request to a server but I keep getting this error

Content-Type is not allowed by Access-Control-Allow-Headers

I've tried adding content-type and access-control-allow-origin to the Access-Control-Allow-Headers at the backend but it still brings up the same error

Searched on Google and I couldn't find a working solution

Please do you know the solution
Re: Backend Devs Please Help Me With A Cors Error by Codepain: 5:56am On Dec 18, 2022
Let's see your code. It's a common error it should be easy to solve
Re: Backend Devs Please Help Me With A Cors Error by Tobedated(op): 8:48am On Dec 18, 2022
Codepain:
Let's see your code. It's a common error it should be easy to solve

Re: Backend Devs Please Help Me With A Cors Error by thug: 9:11am On Dec 18, 2022
install cors and use it as a middleware
Re: Backend Devs Please Help Me With A Cors Error by QuoteJustOnce: 12:34pm On Dec 19, 2022
app.use(cors()) will help you, use all you want during your development... but unsafe for production

for production, something more like below is sufficient.

https://i.imgur.com/2mJG5Uw.png

Then pass the delegate to it, like so
app.use(cors(corsOptionsDelegate))
Re: Backend Devs Please Help Me With A Cors Error by Sleekcode: 10:14pm On Dec 19, 2022
QuoteJustOnce:
app.use(cors()) will help you, use all you want during your development... but unsafe for production

for production, something more like below is sufficient.

https://i.imgur.com/2mJG5Uw.png

Then pass the delegate to it, like so
app.use(cors(corsOptionsDelegate))
You forget to tell him at the top of his code before making any request
1 Reply

Pro JS Devs, Please Is This Variable Chaining • So There Are Devs That Earn Up To 30k USD. • Backend Devs How Do You Advertise Your Skills? • 2 • 3 • 4

Microsoft To Cut 11,000 Jobs In Mass Layoff • I Need Someone To Help Me Wit Php Programming Language • I Need Codes For Printer Friendly Site