Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for host parameter used by Shopify App Bridge 2.0 #23

Open
jmurty opened this issue Feb 23, 2022 · 1 comment
Open

Add support for host parameter used by Shopify App Bridge 2.0 #23

jmurty opened this issue Feb 23, 2022 · 1 comment

Comments

@jmurty
Copy link

jmurty commented Feb 23, 2022

Thanks for this awesome library! It has saved me a lot of time getting started with Shopify app development.

In case anyone is still working on this library...

The newer version 2 of Shopify App Bridge requires a new host parameter in the @shopify/app-bridge-react AppProvider config instead of the previous shopOrigin parameter. This host parameter isn't recognised or passed on by the authenticateShopifyPage() function.

Ideally this library would detect when the host parameter is present, store it in a cookie or browser storage, and provide in the result of authenticateShopifyPage() and it wherever else it's likely to be needed client-side. The parameter needs to be stored because it isn't available on every page load

For now I'm doing this ☝️ in my own app, but it would be nice to get it from the library.

See https://shopify.dev/apps/tools/app-bridge/migrating and https://shopify.dev/apps/tools/app-bridge/retrieve-the-host

@dottodot
Copy link

you can access it in afterAuth using req.query.host

  async afterAuth({
    shopOrigin,
    shopifyToken,
    shopifyAssociatedUser,
    req,
    res,
  }) {
    let redirectUrl = `/?host=${req.query.host}`;
    console.log(
      `We're authenticated on shop ${shopOrigin}: ${shopifyToken} with user ${JSON.stringify(
        shopifyAssociatedUser
      )}`
    );
    res.writeHead(302, { Location: redirectUrl });
    res.end();
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants