Setup CORS for Express app
17 March 2022 (Updated 7 April 2022)
Install package:
npm i cors
Install typings if using TypeScript:
npm i --save-dev @types/cors
Enable middleware:
import express from 'express'
import cors from 'cors'
const app = express()
app.use(cors({ origin: '<front-end-url>' }))
Tagged:
Express
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment