Home

Published

- 1 min read

how to remove cors error from node app

img of how to remove cors error from node app

The solution for this is noted below

how to remove cors error from node app

Solution

   app.use(function (req, res, next) {
	res.setHeader('Access-Control-Allow-Origin', '*')
	res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE')
	res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
	res.setHeader('Access-Control-Allow-Credentials', true)
	next()
})

Try other methods by searching on the site. That is if this doesn’t work