Closed HarshaKDeltaX closed 7 months ago
Hi, sorry to hear you're having issues. In general, this is what happens after OAuth:
isEmbeddedApp
config in shopifyApp
is true
), it will read the host
search param and take the user thereCan you please double check:
host
value is correct when /auth/callback
is called (assuming you're using the default template settings). It is a base64 string, so you'll need to decode it
Hope this helps!
Hi @paulomarg, It's an Embedded app which is configured as an embedded app from both in code and partners dashboard.
Even for the OAuth it's been redirected to the App's root.
Confirmation for IsEmbedded App:
Code: shopify.server.js const shopify = shopifyApp({ apiKey: process.env.SHOPIFY_API_KEY, apiSecretKey: process.env.SHOPIFY_API_SECRET || "", apiVersion: LATEST_API_VERSION, scopes: process.env.SCOPES?.split(","), appUrl: process.env.SHOPIFY_APP_URL || "", authPathPrefix: "/auth", sessionStorage: new PrismaSessionStorage(prisma), distribution: AppDistribution.AppStore, restResources, webhooks: { APP_UNINSTALLED: { deliveryMethod: DeliveryMethod.Http, callbackUrl: "/webhooks", }, }, hooks: { afterAuth: async ({ session }) => { shopify.registerWebhooks({ session }); }, }, ...(process.env.SHOP_CUSTOM_DOMAIN ? { customShopDomains: [process.env.SHOP_CUSTOM_DOMAIN] } : {}), isEmbeddedApp: true });
Partners Dashboard:
Hey, so it sounds like your configuration is correct for an embedded app.
It's normal for the redirect_uri
in the OAuth request to go back to the app. The flow goes:
/auth
=> Shopify (shows grant page to merchant) => /auth/callback
=> <store>/apps/<id>
The app needs to receive the callback as a confirmation that the process was successful to complete the installation.
It sounds like there could be something going wrong in your callback. I would suggest that you check the host
search param in the /auth/callback
request (it's a base64 string so you'll have to decode it). If that value points to your app and not the store, there could be a bug here.
Hey @paulomarg, Recorded the URL for auth/callback
host: YWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvYWtvLWRldi1zdG9yZQ
Decoded value: admin.shopify.com/store/ako-dev-store
the query param is right, but still it redirects to https://measurementapp.mediabuy.pro/store/ako-dev-store
Hmm, this is quite strange - I don't think we've had other reports of this happening, and based on the code it should be working - when the callback completes, it'll call redirectToShopifyOrAppRoot
.
That function will run this:
const redirectUrl = api.config.isEmbeddedApp
? await api.auth.getEmbeddedAppUrl({rawRequest: request})
: `/?shop=${shop}&host=${encodeURIComponent(host)}`;
which calls getEmbeddedAppUrl
if the app is embedded. That function runs
return `https://${decodedHost}/apps/${config.apiKey}`;
so I can't really see how this would be happening if the callback worked, other than the app having an afterAuth
hook configured that takes it to /
instead.
Hi @paulomarg, I walked through the node_modules to out the issue. Found out that there is an issue with my hosting style. I'm basically running this app in a docker container and used IIS as a reverse proxy.
Issue: My response headers are overwritten by the app's root. Which is where it's taking the host from.
Expectation: The expectation is that it should have the
After updating this setting, I can see the response header got updated to
And finally it got resolved, It's getting redirected to the right URL.
Thank you so much for your quick response; I really appreciate It.
Glad to hear you figured it out! Also, thank you for sharing your solution in case others also run into this kind of issue!
Issue summary
Remix Installed app getting redirected to the App's URL instead of admin portal(admin.shopify.com)
This is happening only on Production env.
@shopify/shopify-app-remix
version: ^1.3.0Node version: v16.17.0
Operating system: Linux
Expected behavior
When the App is installed it should stay in the admin protal and complete the Auth. In my case it's redirected to the https://{MyAppURL}/store/{StoreName}/apps/{AppId} Instead of https://admin.shopify.com/store/{StoreName}/apps/{AppId}
Actual behavior
It should be expected to redirect to the admin portal of the shopify.
When I update the app URL to admin.shopify.com, I can access my Application.
Updated https://measurementapp.mediabuy.pro/store/ako-dev-store/apps/6f274f83543385cee3c49e0b9e9c1cf6 to https://admin.shopify.com/store/ako-dev-store/apps/6f274f83543385cee3c49e0b9e9c1cf6 It worked for me