From 64646e36c5e1dd7b701022518fb70cc6ef719164 Mon Sep 17 00:00:00 2001 From: Omar Alaaeldein Date: Fri, 3 Jul 2026 19:03:09 -0400 Subject: [PATCH] fix: use canonical www.codebuff.com URL for fallbacks When fallback URLs point to codebuff.com, the server redirects to www.codebuff.com with a 301 redirect. During this redirect, Node's fetch client strips the Authorization header (for security reasons), causing validation/session requests to fail with a 401 Unauthorized. This changes hardcoded fallbacks to the canonical www.codebuff.com to avoid redirect-induced credential stripping. --- cli/src/hooks/use-freebuff-session.ts | 2 +- cli/src/utils/error-handling.ts | 2 +- sdk/src/validate-agents.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/src/hooks/use-freebuff-session.ts b/cli/src/hooks/use-freebuff-session.ts index b025289ca8..54fa90f51f 100644 --- a/cli/src/hooks/use-freebuff-session.ts +++ b/cli/src/hooks/use-freebuff-session.ts @@ -56,7 +56,7 @@ const playAdmissionSound = () => { const sessionEndpoint = (): string => { const base = ( - env.NEXT_PUBLIC_CODEBUFF_APP_URL || 'https://codebuff.com' + env.NEXT_PUBLIC_CODEBUFF_APP_URL || 'https://www.codebuff.com' ).replace(/\/$/, '') return `${base}/api/v1/freebuff/session` } diff --git a/cli/src/utils/error-handling.ts b/cli/src/utils/error-handling.ts index 2944941138..449164a130 100644 --- a/cli/src/utils/error-handling.ts +++ b/cli/src/utils/error-handling.ts @@ -10,7 +10,7 @@ import type { import { IS_FREEBUFF } from './constants' -const defaultAppUrl = env.NEXT_PUBLIC_CODEBUFF_APP_URL || 'https://codebuff.com' +const defaultAppUrl = env.NEXT_PUBLIC_CODEBUFF_APP_URL || 'https://www.codebuff.com' // Normalize unknown errors to a user-facing string. const extractErrorMessage = (error: unknown, fallback: string): string => { diff --git a/sdk/src/validate-agents.ts b/sdk/src/validate-agents.ts index db21af7224..52950bf468 100644 --- a/sdk/src/validate-agents.ts +++ b/sdk/src/validate-agents.ts @@ -26,7 +26,7 @@ export interface ValidateAgentsOptions { /** * The base URL of the Codebuff website API. * Optional - defaults to NEXT_PUBLIC_CODEBUFF_APP_URL or environment-based URL. - * Example: 'https://codebuff.com' + * Example: 'https://www.codebuff.com' */ websiteUrl?: string }