Is there a way to change the main URL from inside the iframe?
For example: I have a list of orders in the embedded app and when you click an order I want it to route the main screen to that order.
Currently it only routes to a relative path for my app.
I have used both the redirect and the history api methods but they only change the url after my app.
Thanks!
OTM
2
Hi, @chandlerw88 ,
This is Evita from On The Map.
If you are using React for your embedded app, then check this out: https://github.com/Shopify/polaris-react/issues/949
Best,
Evita
I’m not using React but was .ADMIN_PATH is what I needed!
Is this in the documentation somewhere or just the source code?
Here is the final code I used. Thank you a ton!
redirect.dispatch(Redirect.Action.ADMIN_PATH, ‘/orders’);
Hi chandlerw88,
You could also use the following instead of hardcoding the path /orders:
redirect.dispatch(Redirect.Action.ADMIN_SECTION, {
name: Redirect.ResourceType.Order,
});
Or to a specific order:
// Go to {shopUrl}/admin/orders/123
redirect.dispatch(Redirect.Action.ADMIN_SECTION, {
name: Redirect.ResourceType.Order,
resource: {
id: '123',
},
});
This is the recommended approach as it will ensure your app continues to work if the path ever changes in the future.
Check out the docs: https://help.shopify.com/en/api/embedded-apps/app-bridge/actions/navigation/redirect#redirect-to-a-named-section-in-shopify-admin
Cheers,
Trish