Cors and expressjs

Note: This post was written a while back but sat in draft. I’ve published this now, but I’m not sure it’s relevant to the latest versions etc. so please bear this in mind.

This is a simple reminder post for myself, please see cors for complete documentation.

To enable CORS within expressjs, add the package

yarn add cors

The import using

import cors from "cors";

and now to use cors within the middleware we use

var server = express()

server.use(cors());