File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { and, eq } from 'drizzle-orm'
55import { type NextRequest , NextResponse } from 'next/server'
66import { getSession } from '@/lib/auth'
77import { getBaseUrl } from '@/lib/core/utils/urls'
8+ import { isSameOrigin } from '@/lib/core/utils/validation'
89import { processCredentialDraft } from '@/lib/credentials/draft-processor'
910import { safeAccountInsert } from '@/app/api/auth/oauth/utils'
1011
@@ -113,7 +114,7 @@ export async function GET(request: NextRequest) {
113114
114115 const returnUrl = request . cookies . get ( 'shopify_return_url' ) ?. value
115116
116- const redirectUrl = returnUrl || `${ baseUrl } /workspace`
117+ const redirectUrl = returnUrl && isSameOrigin ( returnUrl ) ? returnUrl : `${ baseUrl } /workspace`
117118 const finalUrl = new URL ( redirectUrl )
118119 finalUrl . searchParams . set ( 'shopify_connected' , 'true' )
119120
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { getSession } from '@/lib/auth'
44import { env } from '@/lib/core/config/env'
55import { getBaseUrl } from '@/lib/core/utils/urls'
66import { generateId } from '@/lib/core/utils/uuid'
7+ import { isSameOrigin } from '@/lib/core/utils/validation'
78import { getScopesForService } from '@/lib/oauth/utils'
89
910const logger = createLogger ( 'ShopifyAuthorize' )
@@ -192,7 +193,7 @@ export async function GET(request: NextRequest) {
192193 path : '/' ,
193194 } )
194195
195- if ( returnUrl ) {
196+ if ( returnUrl && isSameOrigin ( returnUrl ) ) {
196197 response . cookies . set ( 'shopify_return_url' , returnUrl , {
197198 httpOnly : true ,
198199 secure : process . env . NODE_ENV === 'production' ,
You can’t perform that action at this time.
0 commit comments