@@ -259,7 +259,21 @@ describe('AuthenticateContext', () => {
259259 } ) ;
260260
261261 describe ( 'auto-proxy for eligible hosts' , ( ) => {
262- it ( 'auto-derives proxyUrl for production instances on eligible hostnames' , async ( ) => {
262+ const originalEnv = process . env ;
263+
264+ beforeEach ( ( ) => {
265+ process . env = {
266+ ...originalEnv ,
267+ VERCEL_TARGET_ENV : 'production' ,
268+ VERCEL_PROJECT_PRODUCTION_URL : 'myapp-abc123.vercel.app' ,
269+ } ;
270+ } ) ;
271+
272+ afterEach ( ( ) => {
273+ process . env = originalEnv ;
274+ } ) ;
275+
276+ it ( 'auto-derives proxyUrl when Vercel env vars indicate production vercel.app' , async ( ) => {
263277 const clerkRequest = createClerkRequest ( new Request ( 'https://myapp-abc123.vercel.app/dashboard' ) ) ;
264278 const context = await createAuthenticateContext ( clerkRequest , {
265279 publishableKey : pkLive ,
@@ -268,7 +282,7 @@ describe('AuthenticateContext', () => {
268282 expect ( context . proxyUrl ) . toBe ( 'https://myapp-abc123.vercel.app/__clerk' ) ;
269283 } ) ;
270284
271- it ( 'does NOT auto-derive proxyUrl for development instances on eligible hostnames ' , async ( ) => {
285+ it ( 'does NOT auto-derive proxyUrl for development keys ' , async ( ) => {
272286 const clerkRequest = createClerkRequest ( new Request ( 'https://myapp-abc123.vercel.app/dashboard' ) ) ;
273287 const context = await createAuthenticateContext ( clerkRequest , {
274288 publishableKey : pkTest ,
@@ -277,8 +291,10 @@ describe('AuthenticateContext', () => {
277291 expect ( context . proxyUrl ) . toBeUndefined ( ) ;
278292 } ) ;
279293
280- it ( 'does NOT auto-derive proxyUrl for ineligible domains' , async ( ) => {
281- const clerkRequest = createClerkRequest ( new Request ( 'https://myapp.com/dashboard' ) ) ;
294+ it ( 'does NOT auto-derive proxyUrl when Vercel env vars are absent' , async ( ) => {
295+ delete process . env . VERCEL_TARGET_ENV ;
296+ delete process . env . VERCEL_PROJECT_PRODUCTION_URL ;
297+ const clerkRequest = createClerkRequest ( new Request ( 'https://myapp-abc123.vercel.app/dashboard' ) ) ;
282298 const context = await createAuthenticateContext ( clerkRequest , {
283299 publishableKey : pkLive ,
284300 } ) ;
0 commit comments