How can I return to the admin product page from an app in Shopify?

RfcSilva
Shopify Partner
17 1 2

Hello,

 

I am developing an Embeded App for Shopify, and I have created an Extension that is on the Admin Product Page on the top menu that opens my App page.

On that page, I want to return to the admin product page that openned the App Page, so I tried to redirect directly to: "https://admin.shopify.com/store/mystore/products/8545732395300".

The problem is that shopify will show an error: Refused to display 'https://admin.shopify.com/' in a frame because it set 'X-Frame-Options' to 'deny'.

How can I do this? A simple redirect is not possible from an App?

Bet regards,

Ricardo

Replies 2 (2)

serkanboztepe
Shopify Partner
23 0 1

I also needed a feature like yours.  Following the steps will likely be beneficial for you too. You can see detail. You can review the details in the document below.

 

https://shopify.dev/docs/api/app-bridge/previous-versions/actions/navigation/redirect-navigate

 

import {useAppBridge} from "@shopify/app-bridge-react";
import {Redirect} from '@shopify/app-bridge/actions';
export default function Create() {
const app = useAppBridge();
const redirect = Redirect.create(app);

redirect.dispatch(Redirect.Action.ADMIN_SECTION, {
name: Redirect.ResourceType.Product,
resource: {
id: '123',
}
});
}
- Need a Shopify developer? Chat on WhatsApp +90-5453606783
- Coffee Tip: Buymeacoffee  | Email: serkanboztepe02@gmail.com
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Best regards,
Serkan Boztepe
RfcSilva
Shopify Partner
17 1 2

Thank you for the answer, but my project is in C#... so I cannot use that...

I ended up with finding a solution, not perfect but a working solution...

 

 

string url = "https://admin.shopify.com/store/" + domain + "/products/" + shopifyProductId.ToString ("");
// Because the App opens in a Frame inside shopify, we need to pass the parameter "_top"
await jsRuntime.InvokeAsync<object> ("open", url, "_top");

 


With this solution, the url request jumps outside the IFrame used by shopify to display the App, and it works.