Shopify / koa-shopify-auth

DEPRECATED Middleware to authenticate a Koa application with Shopify
MIT License
80 stars 64 forks source link

Offline mode - Endless redirects #58

Closed rac146 closed 3 years ago

rac146 commented 3 years ago

Issue summary

When using v4 and setting accessMode 'offline', after a successful authentication the application will not redirect properly to the application home page. Instead it redirects to the 'fallbackRoute' and starts performing endless redirects to itself.

Expected behavior

Prior to v4, accessMode 'offline' still loaded the application correctly after authentication. Should we be using online mode exclusively now and then requesting an offline token separately after a successful authentication?

paulomarg commented 3 years ago

Hi @rac146, there is currently an issue with offline mode, we're working on a fix!

paulomarg commented 3 years ago

We've released v4.0.2 which should fix this issue.

Note: if you're using verifyRequest, please make sure that you're calling verifyRequest({accessMode: 'offline'}) to ensure it works for offline tokens.

hta218 commented 3 years ago

This bug occurs again in v4.1.2

This is my server.js (The project created by shopify-cli version 1.12.0, the only thing I changed in server.js is added the accessMode: 'offline')

app.prepare().then(async () => {
  const server = new Koa();
  // ...
  server.use(
    createShopifyAuth({
      accessMode: 'offline',
      async afterAuth(ctx) {
        // Access token and shop available in ctx.state.shopify...
      }
  });
  // ....
  router.get("(.*)", verifyRequest({ accessMode: 'offline' }), handleRequest); // Everything else must have sessions
}

Can you take a look? @paulomarg