What's your biggest current challenge? Have your say in Community Polls along the right column.

Redirect not working in remix app

Redirect not working in remix app

apochocolate
Shopify Partner
1 0 0

Hi,

 

I'm trying to do a redirect in the loader of my remix app and things are working fine in development. However, in production the redirect works but it doesn't seem like any of the javascript is loaded so none of the interactions work. I noticed that the path in the URL doesn't have the `/app/onboard` at the end.

I'm just doing a simple redirect based on a boolean from prisma.

export async function loader({ request }) {
  const { admin, session, redirect } = await authenticate.admin(request);
  const shopData = await admin.rest.resources.Shop.all({ session: session });
const shopDomain = shopData?.data[0].domain; let merchant = await prisma.merchant.findFirst({ where: { shop: shopDomain} }) if (!merchant?.onboarding_complete) { return redirect(`/app/onboard`);
# url redirect to is https://admin.shopify.com/store/dipsy-doodle-boutique/apps/littleregistry-prod, would expect https://admin.shopify.com/store/dipsy-doodle-boutique/apps/littleregistry-prod/app/onboard }

 

 

Reply 1 (1)

TechSprout
Shopify Partner
19 2 2

Hi @apochocolate , it looks like the issue is that in production this code runs on the server side, different from development (reason why it works on the second but not on the first). If your app runs in an admin iframe, have you tried using Shopify.Context.redirect to handle navigation within it?

 

All the best!

TechSprout - Commerce Solutions
If this post helped, please "Like" and "Mark as Solution" to help others with the same issue. Send me a DM if you have any other questions.