Shopify / Shopify/shopify_app

Fullpage redirect in embedded apps using shopify_app/shared/redirect stopped working

Open
#1,728 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.9k
Forks
739
Avg merge
21h 2m
Merged PRs (30d)
1

Description

Issue summary

I have been using the shopify_app/shared/redirect page to do page redirects in my app. The way that it was working was that if you land on the root page, if you haven't signed up for a plan you get redirected in a before_action to the plans page. However as of yesterday (as far as I can confirm) the shopify_app/shared/redirect template renders on the page but nothing happens. I can confirm there is no change from my side but appears to be a change from the Shopify side.

  • shopify_api version: 12.5.0
  • shopify_app version: 21.4.0
  • Ruby version: 3.1.2
  # This is inspired by the fullpage_redirect_to used in different places in shopify_app
  def embedded_redirect_to(path)
    if ShopifyApp.configuration.embedded_app?
      raise ::ShopifyApp::ShopifyDomainNotFound if current_shopify_domain.blank?
      raise ::ShopifyApp::ShopifyHostNotFound if params[:host].blank?

      url = ShopifyAPI::Auth.embedded_app_url(params[:host]) + path

      render("shopify_app/shared/redirect", layout: false,
        locals: { url: url, current_shopify_domain: current_shopify_domain })
    else
      redirect_to(path)
    end
  end

Expected behavior

The view renders but then quickly redirects to the relevant page.

Actual behavior

The view renders but redirection doesn't happen.

Screenshot 2023-09-28 at 11 30 54 AM

Steps to reproduce the problem

  1. Redirect to another page using shopify_app/shared/redirect like mentioned in the method above in a before_action when loading any page.

Hypothesis

Something has changed from Shopify or the App Bridge utils used to redirect. I have a temporary solution where I load my React page and then trigger a redirect using the below. So maybe the solution is to just change the redirection solution.

export const redirectTo = (path) => {
  const app = createShopifyApp()
  const redirect = Redirect.create(app)
  redirect.dispatch(Redirect.Action.APP, path)
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the shopify_app/shared/redirect template and the embedded_redirect_to method shown in the report, then compare their behavior with the Shopify App Bridge Redirect example. Reproduce the issue with shopify_api 12.5.0 and shopify_app 21.4.0. Done means an embedded app redirects from the rendered page to the requested path as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, ruby
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.