Shopify app don`t redirect to home page after OAUTH

After install app i get access token and other data for auth, and i am need to redirect to home page. I DON`T use KOA-SHOPIFY-AUTH library. My code part:

router.get('/onInstall', (ctx, next) => {
 const { shop } = ctx.request.query;
 const redirectUri = `https://${ctx.request.headers.host}/onInstallFinish`;
 console.log(redirectUri);
 ctx.redirect(`https://${shop}/admin/oauth/authorize?client_id=${API_KEY}&scope=${API_SCOPE}&redirect_uri=${redirectUri}`);
 next(ctx)
});

router.get('/onInstallFinish', (ctx, next) => {
 const { shop, code } = ctx.request.query;
 ACTIVE_SHOPIFY_SHOPS.shop = shop;

 axios.post(`https://${shop}/admin/oauth/access_token`, {
   client_id: API_KEY,
   client_secret: API_SECRET,
   code
 }).then((response) => {
     ACTIVE_SHOPIFY_SHOPS.accessToken = response.data.access_token;
     const host = ctx.query.host;
     ACTIVE_SHOPIFY_SHOPS.host = host;
     console.log(shop);
     ctx.redirect(`/?shop=${shop}&host=${host}`);
     })
   .catch((er
IFY_SHOPS.shop = shop;

});

directUri);
ctx.redirect(`https://${shop}/admin/oauth/authorize?client_id=${API_KEY}&scope=${API_SCOPE}&redirect_uri=${redirectUri}`);
next(ctx)
});

router.get('/onInstallFinish', (ctx, next) => {
const { shop, code } = ctx.request.query;
ACTIVE_SHOPIFY_SHOPS.shop = shop;

});​

@Xsalay I’m also stuck on above, have you figured out the solution.

Thanks in advance!!

hi, i have the same probleme when i use nodejs+koa and nodejs+express but i finally i understand that how work first we redirect to authoriezd url then in callback function don-t use ctx.redirect ( this function use redirection by meta refresh ) to resolve this probleme you need use redirection javascrit if koa use( ctx.type=‘html’; ctx.body=‘your javascript code’:wink: if express use res.write(‘your javascript code’);res.sent(); )

we find what you want about Oauth app in this page : https://shopify.dev/docs/apps/auth/embedded-auth-tutorial?extension=javascript