-
Notifications
You must be signed in to change notification settings - Fork 462
fix(nextjs): add auto proxy opt-out #9159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@clerk/backend': patch | ||
| '@clerk/nextjs': patch | ||
| '@clerk/shared': patch | ||
| --- | ||
|
|
||
| Add `CLERK_DISABLE_AUTO_PROXY=true` to opt out of automatic Frontend API proxying on Vercel production deployments. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,17 @@ describe('mergeNextClerkPropsWithEnv', () => { | |
| expect(result.proxyUrl).toBe(''); | ||
| }); | ||
|
|
||
| it('does not auto-derive proxyUrl when auto-proxy is disabled', () => { | ||
| process.env.CLERK_DISABLE_AUTO_PROXY = 'true'; | ||
| process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY = 'pk_live_Zm9vLmNsZXJrLmNvbSQ='; | ||
| process.env.VERCEL_TARGET_ENV = 'production'; | ||
| process.env.VERCEL_PROJECT_PRODUCTION_URL = 'myapp.vercel.app'; | ||
|
|
||
| const result = mergeNextClerkPropsWithEnv({}); | ||
|
|
||
| expect(result.proxyUrl).toBe(''); | ||
| }); | ||
|
Comment on lines
+52
to
+61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Keep environment-sensitive tests deterministic. Both suites can inherit
🧰 Tools🪛 Betterleaks (1.6.1)[high] 54-54: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) 📍 Affects 2 files
🤖 Prompt for AI Agents |
||
|
|
||
| it('does not override an explicit proxyUrl', () => { | ||
| process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY = 'pk_live_Zm9vLmNsZXJrLmNvbSQ='; | ||
| process.env.VERCEL_TARGET_ENV = 'production'; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: clerk/javascript
Length of output: 9457
🏁 Script executed:
Repository: clerk/javascript
Length of output: 4975
🏁 Script executed:
Repository: clerk/javascript
Length of output: 547
🏁 Script executed:
Repository: clerk/javascript
Length of output: 11562
Add coverage for the auto-proxy opt-out branch.
clerkMiddlewaremakes this decision independently, so add a middleware test withCLERK_DISABLE_AUTO_PROXY=true, a live key, and an eligible Vercel hostname, and assert the proxy handler is skipped.🤖 Prompt for AI Agents
Source: Coding guidelines