Shopify / Shopify/shopify_app

Correct way to redirect

Open
#1,934 6 comments 0 reactions 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

Overview/summary

Hi,
We use Turbolinks and have no trouble using UJS redirect. However, if we need to do a html-based redirect, what is the proper way to do this?

In shopify_app 22.2.1, we used to do the following by adding the shop params already in the original request

In controller (after authentication):

respond_to do |format|
  format.html {
    @redirect_to = edit_orders_path(shop: params[:shop])
  }
end

Then in html.erb, we have:

Turbolinks.visit("<%= @redirect_to %>");

However, in shopify_app 22.5.1, that doesn't work we get ShopifyAPI::Errors::InvalidJwtTokenError, with message "Error decoding session token"

Any suggestions?

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 comparing the controller's respond_to block and the html.erb template using Turbolinks.visit, focusing on the change from shopify_app 22.2.1 to 22.5.1. Reproduce the redirect after authentication and trace the resulting ShopifyAPI::Errors::InvalidJwtTokenError. Done means the supported HTML redirect path no longer produces the session-token decoding error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.