From a430eae12bda27abbd7982becf01adfbb003b04d Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Wed, 25 Jan 2023 08:47:13 -0800 Subject: [PATCH] Merged #1752. --- lib/middleware.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/middleware.js b/lib/middleware.js index 8189ea66..b76a9d40 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -3,7 +3,12 @@ import cors from 'cors'; import { getSession } from './session'; import { getAuthToken, getShareToken } from './auth'; -export const useCors = createMiddleware(cors()); +export const useCors = createMiddleware( + cors({ + // Cache CORS preflight request 24 hours by default + maxAge: process.env.CORS_MAX_AGE || 86400, + }), +); export const useSession = createMiddleware(async (req, res, next) => { let session;