Skip to content

Commit afcd09e

Browse files
Avoid storefront routes in local development
1 parent b2836db commit afcd09e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/shopify_api/auth/oauth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def begin_auth(shop:, redirect_path:, is_online: true, scope_override: nil)
4747

4848
query_string = URI.encode_www_form(query)
4949

50-
auth_route = "https://#{shop}/admin/oauth/authorize?#{query_string}"
50+
auth_route = "https://#{shop.sub(".my.shop.dev", ".dev-api.shop.dev")}/admin/oauth/authorize?#{query_string}"
5151
{ auth_route: auth_route, cookie: cookie }
5252
end
5353

lib/shopify_api/clients/http_client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def request(request, response_as_struct: false)
3939
headers = @headers
4040
headers["Content-Type"] = T.must(request.body_type) if request.body_type
4141
headers = headers.merge(T.must(request.extra_headers)) if request.extra_headers
42+
if headers["Host"].include?(".my.shop.dev")
43+
headers["x-forwarded-host"] = headers["Host"]
44+
headers["Host"] = "app.shop.dev"
45+
end
4246

4347
tries = 0
4448
response = HttpResponse.new(code: 0, headers: {}, body: "")

0 commit comments

Comments
 (0)