From 7b145c1469a81c426e9f0e148671dd7ad6c945f4 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Mon, 22 Jun 2026 06:51:56 +0000 Subject: [PATCH] fix(dashboard): use /api/v1/saas path for subdomain workspace resolution The edge middleware resolved the workspace by calling the SaaS landlord at /api/saas/workspaces/by-subdomain/, but the landlord serves that route under /api/v1/saas/... (the garage backend already calls it with /v1). The missing version segment returned 404, so no workspace_uuid/api_base_url cookies were set and the proxy responded "Workspace session not found", blocking email/password login on a cold visit to .reparee.com/login. Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/dashboard/middleware.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/middleware.ts b/apps/dashboard/middleware.ts index 1d261b6..2a9af08 100644 --- a/apps/dashboard/middleware.ts +++ b/apps/dashboard/middleware.ts @@ -8,7 +8,7 @@ import { NextRequest, NextResponse } from "next/server" * - Skips for the shared fallback host `tenant.reparee.com` and any non-tenant * host (apex, localhost, preview URLs). * - For a tenant subdomain, HMAC-signs the subdomain and calls SaaS - * `GET /api/saas/workspaces/by-subdomain/` to resolve to + * `GET /api/v1/saas/workspaces/by-subdomain/` to resolve to * { workspace_uuid, api_base_url }, then sets those as HttpOnly cookies. * * Matcher excludes /api/proxy/* (proxy needs no resolution; cookies already set) @@ -47,7 +47,7 @@ export async function middleware(req: NextRequest) { try { const signature = await hmacSha256Hex(sub, secret) - const resolveUrl = `${saasUrl.replace(/\/$/, "")}/api/saas/workspaces/by-subdomain/${encodeURIComponent(sub)}` + const resolveUrl = `${saasUrl.replace(/\/$/, "")}/api/v1/saas/workspaces/by-subdomain/${encodeURIComponent(sub)}` const res = await fetch(resolveUrl, { headers: { "X-SaaS-Signature": signature, Accept: "application/json" }, cache: "no-store",