express cors error

  1. Install the cors package using npm:
npm install cors
  1. Import the cors package in your Node.js app:
const cors = require('cors');
  1. Use the cors middleware in your Node.js app with the required options:
app.use(cors());