What is CORS, and how can you enable it in Express.js?

CORS (Cross-Origin Resource Sharing) allows restricted resources on a web page to be requested from another domain. You can enable CORS in an Express application using the cors middleware:

const cors = require('cors');
const express = require('express');
const app = express();

app.use(cors()); // Enables CORS for all routes