diff --git a/apps/api/src/routes/event.router.ts b/apps/api/src/routes/event.router.ts index c48e1e50..ed23ecf9 100644 --- a/apps/api/src/routes/event.router.ts +++ b/apps/api/src/routes/event.router.ts @@ -1,6 +1,6 @@ import { isBot } from '@/bots'; import * as controller from '@/controllers/event.controller'; -import { validateSdkRequest } from '@/utils/auth'; +import { SdkAuthError, validateSdkRequest } from '@/utils/auth'; import { logger } from '@/utils/logger'; import type { FastifyPluginCallback, FastifyRequest } from 'fastify'; @@ -18,7 +18,9 @@ const eventRouter: FastifyPluginCallback = (fastify, opts, done) => { ) => { try { const client = await validateSdkRequest(req.headers).catch((error) => { - logger.error(error, 'Failed to validate sdk request'); + if (!(error instanceof SdkAuthError)) { + logger.error(error, 'Failed to validate sdk request'); + } return null; }); if (!client?.projectId) { diff --git a/apps/api/src/routes/profile.router.ts b/apps/api/src/routes/profile.router.ts index 2c9f1111..891ddeaf 100644 --- a/apps/api/src/routes/profile.router.ts +++ b/apps/api/src/routes/profile.router.ts @@ -1,6 +1,6 @@ import { isBot } from '@/bots'; import * as controller from '@/controllers/profile.controller'; -import { validateSdkRequest } from '@/utils/auth'; +import { SdkAuthError, validateSdkRequest } from '@/utils/auth'; import { logger } from '@/utils/logger'; import type { FastifyPluginCallback } from 'fastify'; @@ -8,7 +8,9 @@ const eventRouter: FastifyPluginCallback = (fastify, opts, done) => { fastify.addHook('preHandler', async (req, reply) => { try { const client = await validateSdkRequest(req.headers).catch((error) => { - logger.error(error, 'Failed to validate sdk request'); + if (!(error instanceof SdkAuthError)) { + logger.error(error, 'Failed to validate sdk request'); + } return null; }); if (!client?.projectId) { diff --git a/apps/api/src/utils/auth.ts b/apps/api/src/utils/auth.ts index 83c2574f..43fd9b38 100644 --- a/apps/api/src/utils/auth.ts +++ b/apps/api/src/utils/auth.ts @@ -11,7 +11,7 @@ const cleanDomain = (domain: string) => .replace(/https?:\/\//, '') .replace(/\/$/, ''); -class SdkAuthError extends Error { +export class SdkAuthError extends Error { payload: { clientId?: string; clientSecret?: string;