To fix CORS error :Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response with Node, we use the cors
package.
To use it, we write
const express = require("express");
const cors = require("cors");
const app = express();
app.use(cors());
app.options("*", cors());
to call app.use
with the middleware returned by cors
to enable CORS in our Express app.