Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@ import { start } from "workflow/api";
import { analysisWorkflow } from "@/workflows/analysis";

export async function POST(request: Request) {
const botIdResult = await checkBotId();
Sentry.logger.debug("BotID check result", {
isBot: botIdResult.isBot,
userAgent: request.headers.get("user-agent"),
});
if (botIdResult.isBot) {
Sentry.logger.warn("BotID check failed", {
isBot: botIdResult.isBot,
userAgent: request.headers.get("user-agent"),
});
return new Response("Access Denied", { status: 403 });
if (process.env.VERCEL_ENV === "production") {
try {
const botIdResult = await checkBotId();
Sentry.logger.debug("BotID check result", {
isBot: botIdResult.isBot,
userAgent: request.headers.get("user-agent"),
});
if (botIdResult.isBot) {
Sentry.logger.warn("BotID check failed", {
isBot: botIdResult.isBot,
userAgent: request.headers.get("user-agent"),
});
return new Response("Access Denied", { status: 403 });
}
} catch (error) {
Sentry.logger.warn("BotID check threw exception", {
error: error instanceof Error ? error.message : String(error),
userAgent: request.headers.get("user-agent"),
});
// Missing verification headers should not crash the request path.
}
}

const analysisStartTime = Date.now();
Expand Down
32 changes: 21 additions & 11 deletions app/api/follow-up-suggestions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,27 @@ const followUpSuggestionsSchema = z.object({
});

export async function POST(request: Request) {
const botIdResult = await checkBotId();
Sentry.logger.debug("BotID check result", {
isBot: botIdResult.isBot,
userAgent: request.headers.get("user-agent"),
});
if (botIdResult.isBot) {
Sentry.logger.warn("BotID check failed", {
isBot: botIdResult.isBot,
userAgent: request.headers.get("user-agent"),
});
return new Response("Access Denied", { status: 403 });
if (process.env.VERCEL_ENV === "production") {
try {
const botIdResult = await checkBotId();
Sentry.logger.debug("BotID check result", {
isBot: botIdResult.isBot,
userAgent: request.headers.get("user-agent"),
});
if (botIdResult.isBot) {
Sentry.logger.warn("BotID check failed", {
isBot: botIdResult.isBot,
userAgent: request.headers.get("user-agent"),
});
return new Response("Access Denied", { status: 403 });
}
} catch (error) {
Sentry.logger.warn("BotID check threw exception", {
error: error instanceof Error ? error.message : String(error),
userAgent: request.headers.get("user-agent"),
});
// Missing verification headers should not crash the request path.
}
}

const startTime = Date.now();
Expand Down
Loading