Development discussions around Shopify APIs
Hello community!
I am trying to deploy Node Shopify Public App on different domains for Frontend and Backend.
Each time I call https://<MY_BACKEND_PATH>/auth?shop=<MY_SHOP> I get HTTP 302 with Location same as original request https://<MY_BACKEND_PATH>/auth?shop=<MY_SHOP>
I have NextJS run as static site on another domain. I have provided all correct Env variables to my Backend. I am using latest Shopify CLI. I have updated my Partner Dashboard correctly.
All is working fine with shopify node server i.e. with ngrok but fails in real life.
What have I missed?
Solved! Go to the solution
This is an accepted solution.
ok, seems having prefix in afterAuth is bad idea since it will not work for case when Koa deployed not on root /. Creating domain name and assigning it to my host's / solved the problem
ok, found issue... that's because I need to use prefix for Koa auth lib. Since I need to prepend each request with /dev/index I enforced to add
server.use(
createShopifyAuth({
prefix: "/dev/index",// I need this to have /dev/index/auth/inline redirect but not /auth/inline since it is not served by my Backend
async afterAuth(ctx) {
console.log("afterAuth", ctx);
// Access token and shop available in ctx.state.shopify
const { shop, accessToken, scope } = ctx.state.shopify;
const host = ctx.query.host;
ACTIVE_SHOPIFY_SHOPS[shop] = scope;
const response = await Shopify.Webhooks.Registry.register({
shop,
accessToken,
path: "/webhooks",
topic: "APP_UNINSTALLED",
webhookHandler: async (topic, shop, body) =>
delete ACTIVE_SHOPIFY_SHOPS[shop],
});
if (!response.success) {
console.log(
`Failed to register APP_UNINSTALLED webhook: ${response.result}`
);
}
// Redirect to app with shop parameter upon auth
ctx.redirect(`${process.env.BACKEND_URL}/?shop=${shop}&host=${host}`);
},
})
);
This is an accepted solution.
ok, seems having prefix in afterAuth is bad idea since it will not work for case when Koa deployed not on root /. Creating domain name and assigning it to my host's / solved the problem
User | RANK |
---|---|
8 | |
7 | |
4 | |
3 | |
3 |
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By