|
@@ -448,10 +448,23 @@ serve(wrapHandler('oauth-shoprenter-callback', async (req) => {
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Redirect to frontend integrations page with installation ID
|
|
|
|
|
- const redirectUrl = `${frontendUrl}/integrations?sr_install=${installationId}&shopname=${encodeURIComponent(shopname)}`
|
|
|
|
|
-
|
|
|
|
|
- console.log(`[ShopRenter] Installation pending for ${shopname}, redirecting to: ${redirectUrl}`)
|
|
|
|
|
|
|
+ // Redirect to app_url (ShopRenter admin) with installation ID
|
|
|
|
|
+ // This allows ShopRenter to redirect back to our EntryPoint with the sr_install parameter
|
|
|
|
|
+ // Per ShopRenter docs: "It is possible to decorate the value of app_url with unique query string parameters"
|
|
|
|
|
+ let redirectUrl: string
|
|
|
|
|
+
|
|
|
|
|
+ if (app_url) {
|
|
|
|
|
+ // Append our installation ID to the app_url
|
|
|
|
|
+ const appUrlObj = new URL(app_url)
|
|
|
|
|
+ appUrlObj.searchParams.set('sr_install', installationId)
|
|
|
|
|
+ appUrlObj.searchParams.set('shopname', shopname)
|
|
|
|
|
+ redirectUrl = appUrlObj.toString()
|
|
|
|
|
+ console.log(`[ShopRenter] Installation pending for ${shopname}, redirecting to app_url: ${redirectUrl}`)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // Fallback: redirect directly to our integrations page if no app_url provided
|
|
|
|
|
+ redirectUrl = `${frontendUrl}/integrations?sr_install=${installationId}&shopname=${encodeURIComponent(shopname)}`
|
|
|
|
|
+ console.log(`[ShopRenter] Installation pending for ${shopname}, no app_url provided, redirecting to: ${redirectUrl}`)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return new Response(null, {
|
|
return new Response(null, {
|
|
|
status: 302,
|
|
status: 302,
|