You can control how long browsers cache the preflight responses using the maxAge
option:
const corsOptions = {
origin: 'http://example.com',
methods: 'GET,POST,PUT,DELETE,OPTIONS',
allowedHeaders: 'Content-Type,Authorization',
credentials: true,
maxAge: 3600, // Cache preflight response for 1 hour
};
app.use(cors(corsOptions));
Leave a Reply