Skip to content

Commit 384d16e

Browse files
committed
on install the shop will not be set, use shopifys param as a fallback
1 parent 6e37f42 commit 384d16e

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

lib/shopify_api/plugs/put_shopify_content_headers.ex

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ defmodule ShopifyAPI.Plugs.PutShopifyContentHeaders do
2020

2121
def call(conn, _options) do
2222
conn
23-
|> put_resp_header("x-frame-options", "ALLOW-FROM https://" <> myshopify_domain(conn))
23+
|> put_resp_header("x-frame-options", "ALLOW-FROM " <> myshopify_domain_url(conn))
2424
|> put_resp_header(
2525
"content-security-policy",
26-
"frame-ancestors https://" <> myshopify_domain(conn) <> " https://admin.shopify.com;"
26+
"frame-ancestors " <> myshopify_domain_url(conn) <> " https://admin.shopify.com;"
2727
)
2828
end
2929

30-
defp myshopify_domain(%{assigns: %{shop: %{domain: domain}}}), do: domain
30+
defp myshopify_domain_url(conn) do
31+
case conn do
32+
%{assigns: %{shop: %{domain: domain}}} -> "https://" <> domain
33+
%{params: %{"shop" => domain}} -> "https://" <> domain
34+
_ -> ""
35+
end
36+
end
3137
end

0 commit comments

Comments
 (0)