Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the shopify theme dev/shopify theme console proxy to handle cookies as expected #3851

Merged
merged 1 commit into from
May 6, 2024

Conversation

karreiro
Copy link
Contributor

@karreiro karreiro commented May 6, 2024

WHY are these changes introduced?

Fixed the shopify theme dev/shopify theme console proxy to handle cookies as expected, and ensured they no longer render the live theme instead of the development theme.

WHAT is this pull request doing?

With the session cookie being renamed, the CLI needed to follow that change [1] [2]. However, the new regular expression captures the ;, which was creating a scenario like this:

This is not an issue when the session cookie is the last one in the cookie string, but when it's in the middle of the string, it depends on the client's fallback behavior, which creates an intermittent behavior.

The browser sometimes is able to infer the cookie correctly, but in scenarios like when the --password flag is passed, where we have the Theme Access app in the middle, the proxy was consistently failing on passing the cookie. Now, we're always appending the ; even when the trailing semicolon is supported.

This PR also removes the storefront_session.nil? from the auth_middleware.rb, which is related to the behavior of rendering the live theme in the context of shopify theme console. Removing this is important because stores that are not password protected don't have that cookie.

How to test your changes?

shopify theme dev

To test this change in the shopify theme dev command, you may run it with the --password flag, or reduce the expiration date on the proxy (to force the cookie update) as the video shows:

Before After
before__dev after__dev

shopify theme console

To test this change in the shopify theme console command, you may run the command on a store that is not password-protected:

Before After
before_console after_console

Post-release steps

None.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've made sure that any changes to dev or deploy have been reflected in the internal flowchart.

Copy link
Contributor

github-actions bot commented May 6, 2024

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-management

Copy link
Contributor

github-actions bot commented May 6, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 71.77% 6943/9674
🟡 Branches 68.72% 3421/4978
🟡 Functions 71.22% 1858/2609
🟡 Lines 73.07% 6544/8956

Test suite run success

1633 tests passing in 763 suites.

Report generated by 🧪jest coverage report action from 6010209

…ookies as expected, and ensure they no longer render the live theme instead of the development theme
@karreiro karreiro removed the request for review from lucyxiang May 6, 2024 08:37
@karreiro karreiro added this pull request to the merge queue May 6, 2024
Merged via the queue into main with commit 0f0f9de May 6, 2024
@karreiro karreiro deleted the fix-cookies-theme-dev branch May 6, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants