diff --git a/apps/web/components/header.tsx b/apps/web/components/header.tsx index 36d10418..6ccac0c5 100644 --- a/apps/web/components/header.tsx +++ b/apps/web/components/header.tsx @@ -20,6 +20,7 @@ import { import { Button } from "@ui/components/button" import { cn } from "@lib/utils" import { dmSansClassName } from "@/lib/fonts" +import { getBillingSettingsUrl } from "@/lib/url-helpers" import { GraphIcon, IntegrationsIcon } from "@/components/integration-icons" import { DropdownMenu, @@ -81,6 +82,7 @@ export function Header({ onAddMemory, onOpenSearch }: HeaderProps) { feedbackParam, ) const { viewMode, setViewMode } = useViewMode() + const billingSettingsUrl = getBillingSettingsUrl() const handleFeedback = () => setFeedbackOpen(true) @@ -357,7 +359,7 @@ export function Header({ onAddMemory, onOpenSearch }: HeaderProps) { asChild className="gap-2.5 rounded-lg px-2.5 py-2 text-sm font-medium text-white/85 hover:bg-white/[0.06] focus:bg-white/[0.06] focus:text-white cursor-pointer" > - + Upgrade @@ -443,10 +445,7 @@ export function Header({ onAddMemory, onOpenSearch }: HeaderProps) { dmSansClassName(), )} > - + Upgrade diff --git a/apps/web/lib/url-helpers.ts b/apps/web/lib/url-helpers.ts index cfd57209..8fc7d29e 100644 --- a/apps/web/lib/url-helpers.ts +++ b/apps/web/lib/url-helpers.ts @@ -1,4 +1,22 @@ const PROXY_LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1"]) +const DEV_APP_ORIGIN = "https://app.dev.supermemory.ai" +const PROD_APP_ORIGIN = "https://app.supermemory.ai" + +export function getAppOriginForCurrentEnvironment(hostname?: string): string { + const currentHostname = + hostname ?? (typeof window !== "undefined" ? window.location.hostname : "") + const normalized = currentHostname.toLowerCase() + const isLocalOrDev = + process.env.NODE_ENV !== "production" || + PROXY_LOCAL_HOSTS.has(normalized) || + normalized.includes("app.dev.supermemory") + + return isLocalOrDev ? DEV_APP_ORIGIN : PROD_APP_ORIGIN +} + +export function getBillingSettingsUrl(hostname?: string): string { + return `${getAppOriginForCurrentEnvironment(hostname)}/settings#billing` +} /** Reconstruct the browser-facing URL when running behind portless (or similar). */ export function getPublicRequestUrl(request: Request): URL {