Shopify Koa missing HOST header

I am trying to generate an offline token with the shops using Shopify CLI for with Koa authentication module.

Something like this:

server.keys = [Shopify.Context.API_SECRET_KEY];
  server.use(
    createShopifyAuth({
      accessMode: "offline",
      async afterAuth(ctx) {
        // Access token and shop available in ctx.state.shopify
        const { shop, accessToken, scope } = ctx.state.shopify;
     })
  )

However, when I try to run this flow with newly created stores, I am getting an error from the Shopify App Bridge, that Host is required, and app fails to render.

class MyApp extends App {
  render() {
    const { Component, pageProps, host, isValidStore } = this.props;

    return (
      
    );
  }
}

I am fetching this using following method:

MyApp.getInitialProps = async ({ ctx }) => {
  return { host: ctx.query.host };
};

It is not able to get the host in the query parameter, probably because Shopify is not passing it. Is there something that I’m missing?

PS:

Package versions are as followed:

"@shopify/app-bridge-react": "2.0.13",
"@shopify/app-bridge-utils": "2.0.13",
"@shopify/koa-shopify-auth": "5.0.3",
"@shopify/polaris": "9.0.0",

Thank you for the help in advance.

Hi @Katarina_Heady . Thanks for reporting this. I’m a PM at Shopify. We’ve fixed this issue and the host parameter is now included.

1 Like