Add maxAge config to cache CORS preflight request

This commit is contained in:
sdvcrx 2023-01-19 18:06:18 +08:00
parent 1d9c3133f0
commit 86aaa5519e
No known key found for this signature in database
GPG Key ID: 126C6DE782791F05

View File

@ -11,7 +11,10 @@ import { getUser } from '../queries';
const log = debug('umami:middleware');
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) => {
const session = await findSession(req);