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

[3.59] Fix shopify theme dev proxy to use development theme #3771

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-badgers-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/theme': patch
---

- Fix the `shopify theme dev` proxy to use the development theme, even when users have a browser session with the live theme loaded
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def call(env)
query = URI.decode_www_form(env["QUERY_STRING"])
replace_templates = build_replacement_param(env)

clean_sfr_cache(env, query, headers)
response = set_preview_theme_id(env, query, headers)
return serve_response(response, env) if response

response = if replace_templates.any?
# Pass to SFR the recently modified templates in `replace_templates` or
Expand Down Expand Up @@ -87,9 +88,7 @@ def call(env)
@core_endpoints << env["PATH_INFO"]
end

body = patch_body(env, response.body)
body = [body] unless body.respond_to?(:each)
[response.code, headers, body]
serve_response(response, env, headers)
end

def secure_session_id
Expand All @@ -105,7 +104,13 @@ def secure_session_id

private

def clean_sfr_cache(env, query, headers)
def serve_response(response, env, headers = get_response_headers(response, env))
body = patch_body(env, response.body)
body = [body] unless body.respond_to?(:each)
[response.code, headers, body]
end

def set_preview_theme_id(env, query, headers)
if env["PATH_INFO"].start_with?("/password")
@cache_cleaned = false
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def call(env)
@env = env
@env["PATH_INFO"] = PASSWORD_PAGE_PATH if redirect_to_password?(@env)

return @app.call(@env) if password_page?(@env)
return @app.call(@env) if password_page?(@env) || (storefront_session.nil? || secure_session.nil?)

authenticate!

Expand Down