Skip to content

Conversation

@brkalow
Copy link
Member

@brkalow brkalow commented Jan 15, 2026

Description

Implements clerkProxy helper that abstracts the complexity of proxying Clerk's Frontend API (FAPI) requests. This enables scenarios where direct communication with Clerk's API is blocked or needs to go through the application server.

Key additions:

  • Core proxy implementation in @clerk/backend/src/proxy.ts with environment-aware FAPI URL derivation
  • Next.js integration via clerkMiddleware option and route handler exports
  • Express middleware for handling proxy requests with streaming body support
  • FAPI URL constants and path matching utilities

Type of change

  • 🌟 New feature

Testing

Manual testing with proxy-enabled Next.js and Express applications will be needed before merge. Proxy request forwarding, header management, and error handling should be verified across all three packages.

…s, and @clerk/express

Implement clerkProxy helper that abstracts away the complexity of proxying Clerk's Frontend API (FAPI) requests. This enables scenarios where direct communication with Clerk's API is blocked or needs to go through the application server.

- Core proxy implementation in @clerk/backend/src/proxy.ts with environment-aware URL derivation
- Next.js integration via clerkMiddleware frontendApiProxy option and route handlers
- Express middleware for handling proxy requests with body streaming support
- FAPI URL constants added to @clerk/shared for environment detection

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Jan 15, 2026

⚠️ No Changeset found

Latest commit: dc1349e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jan 16, 2026 8:23pm

Request Review

- Add comprehensive tests for @clerk/backend/proxy including FAPI URL derivation, path matching, and request forwarding
- Add tests for @clerk/nextjs/proxy route handlers and exports
- Add tests for @clerk/express/proxy middleware and request conversion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The Next.js proxy tests mocked the underlying @clerk/backend/proxy,
making them essentially test that wrapper A calls function B - no real
behavior was verified. The backend proxy tests provide actual coverage.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@brkalow brkalow changed the title feat: Add Frontend API proxy helpers feat(backend): Add Frontend API proxy helpers Jan 15, 2026
Allow the `enabled` option in `frontendApiProxy` to accept a function
`(url: URL) => boolean` for conditional proxy based on the request URL.

This enables scenarios where an application has multiple domains and
only some require proxying (e.g., `foo.replit.app` proxied while
`foo.com` uses direct FAPI access).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants