【发布时间】:2019-04-09 02:24:30
【问题描述】:
我正在尝试以phoenix-framework 作为后端制作一个shopify 应用程序。我一直关注this tutorial 在shopify 后台加载我的应用,我需要修改x-frame-options 标头。
这是我的插头:
@doc false
def init(opts \\ %{}), do: Enum.into(opts, %{})
@doc false
def call(%{params: %{"shop" => shopify_domain}} = conn, _opts) do
IO.puts("++++++++++ Plug Call ++++++++++++++")
IO.inspect(shopify_domain)
# %{"shopify_domain" => shopify_domain_only} = shopify_domain
shop = ShopifyApp.find_shop_by(shopify_domain)
allow_shop_or_halt(conn, shop)
end
def call(conn, _opts), do: conn
defp allow_shop_or_halt(conn, nil), do: Conn.halt(conn)
defp allow_shop_or_halt(conn, shop) do
conn
|> Conn.put_private(:shop, shop)
|> Conn.put_resp_header("x-frame-options", "ALLOW-FROM https://#{shop.shopify_domain}/")
end
但是 Chrome 浏览器中的控制台抱怨:
加载时遇到无效的“X-Frame-Options”标头.....: ALLOW-FROM https://skbeautysupply.myshopify.com/' 无法识别 指示。标题将被忽略。
我在这里错过了什么?
【问题讨论】:
-
尝试小写
allow-from -
@denis.peplin 是的,我做了,但没用。 :(
标签: shopify phoenix-framework elixir phoenix-framework x-frame-options