Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
85 stars 9 forks source link

admin.shopify.com change causing hostOrigin to be the same across all stores #177

Closed gil-- closed 1 year ago

gil-- commented 1 year ago

Describe the bug

Unable to retrieve the myShopify url via hostOrigin on latest app bridge as Shopify now returns https://admin.shopify.com for all stores. Can we fix this or introduce a new parameter to assist with retrieval of the shop url.

To Reproduce

Steps to reproduce the behaviour:

Use @shopify/app-bridge-react and:

    const app = useAppBridge();
    const redirect = Redirect.create(app);
    const hostOrigin = redirect.hostOrigin;

hostOrigin will be https://admin.shopify.com.

image

Expected behaviour

I'd expect host origin to be the shop's url. Otherwise, please surface myshopify as a new parameter.

Packages and versions

List the relevant packages you’re using, and their versions. For example:

Platform

Additional context

Add any other context about the problem here, such as your app’s configuration (Node, Next.js, Rails).

joeyfreund commented 1 year ago

Hi @gil-- , thanks for bringing it up.

The hostOrigin property wasn't meant to be part of App-Bridge's public API. Unfortunately, we didn't make it explicit.
(Hyrum's Law never gets old).

In any case, there are multiple ways to get the myshopify.com domain:

  1. When your app loads, Shopify sends it as the shop query string parameter.
  2. From the session token (you'll need to decode the token first, jwt-decode or any similar library will do the trick)

Please let me know if this solves your problem.

joeyfreund commented 1 year ago

Closing this. @gil-- , if you have any follow-up questions, please feel free to re-open this issue.

CodaemonHaroon commented 1 year ago

Hi there, I am using laravel 8 with laravel/ossiset package. I have follow this link => https://clickysoft.com/shopify-laravel-app-development/ to install and configure all the things. The app is working fine on this URL => https://[STORE NAME].myshopify.com/admin/apps/[APP NAME]/ When i click on any of the left side links of shopify like Products and Orders the URL is changed to => https://admin.shopify.com/store/[STORE NAME]/products?selectedView=all If I want to switch back to the APP the URL is Chnaged to => https://admin.shopify.com/store/[STORE NAME]/apps/[APP NAME] Then the APP shows only blank screen. Any help will be appriciated.

henrytao-me commented 1 year ago

@CodaemonHaroon Can I have the app id? I can take a look. It's not a sensitive info but if you don't want to send it here, you can ping me on partners slack.

CodaemonHaroon commented 1 year ago

@henrytao-me I have refer this link to solve the issues. And the App is working. https://github.com/gnikyt/laravel-shopify/issues/1248 [Reffered link] The code of filipembcruz and it is working. But now i am facing the Ajax call issues. It is always redirecting to 302 error page. I have disabled the VerrifyCsrfToken middleware but no luck.

henrytao-me commented 1 year ago

I don't have experience with the PHP library. I am afraid that I cannot help much here.