Skip to content

Commit

Permalink
fix: add auth cors header mw
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Sep 11, 2024
1 parent 9cffdd2 commit fc6c80a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/development.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
module.exports = {
server: {
session: {
cookieSecret: 'xxx',
},
},
redis: {
url: 'redis://localhost:16379',
socket: {
Expand Down
3 changes: 2 additions & 1 deletion src/limits/route/get-limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
const [ rateLimitState, remainingCredits ] = await Promise.all([
Expand All @@ -23,5 +24,5 @@ const handle = async (ctx: ExtendedContext): Promise<void> => {
};

export const registerLimitsRoute = (router: Router): void => {
router.get('/limits', '/limits', authenticate(), handle);
router.get('/limits', '/limits', corsAuthHandler(), authenticate(), handle);
};

0 comments on commit fc6c80a

Please sign in to comment.