How to get the shop when clicking the App from admin navigation when coming from a page within the app?

39 views Asked by At

When I click my app link in the Admin navigation, I am able to access my app as expected.

I see this from the request:

req.query {
  embedded: '1',
  hmac: '97473938af0754fbe44b25cac5f8c9b0b6a96f4621acb50097b3333504e38c09',
  host: 'YWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvc24tZXJpYy1sb2NhbC0z',
  locale: 'en',
  prefetch: '1',
  session: 'ec689c3ec72574023d1303bc053b6077ceef8167fffcb7c7a92f781f728baec5',
  shop: 'sn-eric-local-3.myshopify.com',
  timestamp: '1698843510'
}

enter image description here

I can also click Page 1 and Page 2 and both of them works.

enter image description here

My issue is, when I click the app again when coming from Page 1 or Page 2, I don't have access to Shopify data. It tries to re-authenticate.

enter image description here

enter image description here

/api/auth/start.js

export default async (req, res) => {
  console.log('req.query', req.query)

  if (!req.query.shop) {
    // I don't have access to the shop url at this point and I need it.
  }
  ...
}

I simply want it to go back to the home page. How will I be able to achieve that?

0

There are 0 answers