feat(fastify): Add Frontend API proxy support#7995
Conversation
Why: Ad blockers and corporate firewalls can block direct connections to Clerk's Frontend API. Express and Next.js already have proxy support, but Fastify didn't, leaving Fastify users without a workaround. What changed: - Added `FrontendApiProxyOptions` type and `frontendApiProxy` option to `ClerkFastifyOptions` - Proxy interception in `withClerkMiddleware` runs before auth: matching requests are converted to Fetch Request, forwarded to FAPI via `clerkFrontendApiProxy`, and streamed back through Fastify's reply - Added `requestToProxyRequest` utility for creating Fetch Requests with real URLs and body streaming from Fastify requests - Auto-derives `proxyUrl` for auth handshake from `x-forwarded-proto`/`x-forwarded-host` headers when proxy is enabled - Added 7 unit tests covering interception, custom paths, disabled/unconfigured states, and proxyUrl derivation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: c056d3a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughThis pull request introduces Frontend API proxy support to the 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
!snapshot |
|
Hey @dominic-clerk - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.3.2-snapshot.v20260306064615 --save-exact
npm i @clerk/astro@3.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/backend@3.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/chrome-extension@3.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/clerk-js@6.0.1-snapshot.v20260306064615 --save-exact
npm i @clerk/dev-cli@0.1.1-snapshot.v20260306064615 --save-exact
npm i @clerk/expo@3.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/expo-passkeys@1.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/express@2.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/fastify@3.1.0-snapshot.v20260306064615 --save-exact
npm i @clerk/hono@0.0.4-snapshot.v20260306064615 --save-exact
npm i @clerk/localizations@4.0.1-snapshot.v20260306064615 --save-exact
npm i @clerk/msw@0.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/nextjs@7.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/nuxt@2.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/react@6.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/react-router@3.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/shared@4.0.1-snapshot.v20260306064615 --save-exact
npm i @clerk/tanstack-react-start@1.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/testing@2.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/ui@1.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/upgrade@2.0.2-snapshot.v20260306064615 --save-exact
npm i @clerk/vue@2.0.2-snapshot.v20260306064615 --save-exact |
This adds a
frontendApiProxyoption toclerkPlugin:What's included:
FrontendApiProxyOptionstype andfrontendApiProxyoption onClerkFastifyOptionswithClerkMiddlewarebefore auth - matching requests are converted to Fetch Request, forwarded to FAPI viaclerkFrontendApiProxy, and streamed back through Fastify's reply using Node.js Readable streamsrequestToProxyRequestutility for creating Fetch Requests with real URLs and body streaming from Fastify requestsproxyUrlfor auth handshake fromx-forwarded-proto/x-forwarded-hostheadersinject()covering interception, custom paths, disabled/unconfigured states, and proxyUrl derivationSummary by CodeRabbit
Release Notes
New Features
Tests