CORS
To install csurf in your project, you can use npm. Run the following command:
npm install corscors as middleware in your Express.js application
const express = require('express');
const cors = require('cors');
const app = express();
const port = 3000;
// Enable CORS for all routes
app.use(cors());
// Routes
app.get('/', (req, res) => {
res.send('Hello, CORS is enabled!');
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
Last updated