You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add serverFetch() helper to lib/api.ts that reads cookies() from
next/headers and forwards them on every internal API call. All 11
protected server components (agency + creator pages) now use
serverFetch() instead of bare fetch(apiUrl()), preventing the
Clerk middleware from redirecting requests to /login and returning
HTML instead of JSON.
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
-**Real Clerk auth wired**: deleted `lib/auth-helpers.ts` (hardcoded stubs). All 9 API routes now call `requireAgencyAuth()` / `requireCreatorAuth()` / `requireBrandAuth()` from `lib/auth.ts`.
10
+
-**ClerkProvider**: `app/layout.tsx` now wraps with `<ClerkProvider>` instead of `<RoleProvider>`.
11
+
-**Deleted `lib/role-context.tsx`**: Clerk is now source of truth for identity.
12
+
-**RoleSwitcher rewrite**: uses `useUser()` from Clerk; renders null for non-superadmin; sets `active_perspective` cookie on change.
13
+
-**Header**: replaced `useRole()` with `useUser()` from Clerk.
14
+
-**Rate limiting**: `lib/rate-limit.ts` rewritten with lazy singletons (`getAuthRateLimit()`, `getUploadRateLimit()`) to prevent build-time crash when Upstash env vars absent.
15
+
-**Resend lazy init**: `jobs/send-email.ts` uses `getResend()` singleton for same reason.
-**`proxy.ts` fix**: added `/api/v1/creators(.*)` to `isPublicRoute` (was causing /discover 500).
23
+
-**`serverFetch()` helper**: added to `lib/api.ts`; all protected server components now forward Clerk session cookie on internal HTTP fetches, fixing `SyntaxError: Unexpected token '<'` on all agency/creator pages.
0 commit comments