Skip to content

Commit f40ccd4

Browse files
committed
shopify
1 parent 5ea64e9 commit f40ccd4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

apps/sim/app/api/auth/oauth2/shopify/store/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { and, eq } from 'drizzle-orm'
55
import { type NextRequest, NextResponse } from 'next/server'
66
import { getSession } from '@/lib/auth'
77
import { getBaseUrl } from '@/lib/core/utils/urls'
8+
import { isSameOrigin } from '@/lib/core/utils/validation'
89
import { processCredentialDraft } from '@/lib/credentials/draft-processor'
910
import { 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

apps/sim/app/api/auth/shopify/authorize/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getSession } from '@/lib/auth'
44
import { env } from '@/lib/core/config/env'
55
import { getBaseUrl } from '@/lib/core/utils/urls'
66
import { generateId } from '@/lib/core/utils/uuid'
7+
import { isSameOrigin } from '@/lib/core/utils/validation'
78
import { getScopesForService } from '@/lib/oauth/utils'
89

910
const 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',

0 commit comments

Comments
 (0)