express js cors

Install the necessary packages using npm:

npm install express cors

In your Node.js application, require the installed packages:

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

Initialize Express and configure CORS:

const app = express();
app.use(cors());

Handle your API endpoints and start the server:

app.get('/example', function(req, res) {
  res.json({ message: 'This is an example response' });
});

app.listen(3000, function() {
  console.log('Server is running on port 3000');
});