Preflight Cache Control

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));

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *