From fc6c80aa2072189949b214e1218be4e4ef97b803 Mon Sep 17 00:00:00 2001 From: Alexey Yarmosh Date: Wed, 11 Sep 2024 19:51:18 +0200 Subject: [PATCH] fix: add auth cors header mw --- config/development.cjs | 5 +++++ src/limits/route/get-limits.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/development.cjs b/config/development.cjs index b94467c8..a6916a27 100644 --- a/config/development.cjs +++ b/config/development.cjs @@ -1,4 +1,9 @@ module.exports = { + server: { + session: { + cookieSecret: 'xxx', + }, + }, redis: { url: 'redis://localhost:16379', socket: { diff --git a/src/limits/route/get-limits.ts b/src/limits/route/get-limits.ts index d8542886..7cc35ec6 100644 --- a/src/limits/route/get-limits.ts +++ b/src/limits/route/get-limits.ts @@ -3,6 +3,7 @@ import { getRateLimitState } from '../../lib/rate-limiter.js'; import type { ExtendedContext } from '../../types.js'; import { credits } from '../../lib/credits.js'; import { authenticate } from '../../lib/http/middleware/authenticate.js'; +import { corsAuthHandler } from '../../lib/http/middleware/cors.js'; const handle = async (ctx: ExtendedContext): Promise => { const [ rateLimitState, remainingCredits ] = await Promise.all([ @@ -23,5 +24,5 @@ const handle = async (ctx: ExtendedContext): Promise => { }; export const registerLimitsRoute = (router: Router): void => { - router.get('/limits', '/limits', authenticate(), handle); + router.get('/limits', '/limits', corsAuthHandler(), authenticate(), handle); };