Shopifex.Plug.LoadInIframe (Shopifex v3.0.0)

Copy Markdown View Source

Allows the response to render inside the Shopify admin iframe.

Phoenix's put_secure_browser_headers/2 blocks cross-origin framing twice: with x-frame-options and, since Phoenix 1.8, with a frame-ancestors 'self' directive in its default content-security-policy. Browsers enforce every CSP header on a response, so leaving that directive in place blocks the admin even when Shopifex.Plug.SetCSPHeader adds its own policy alongside it.

This plug deletes x-frame-options and drops the frame-ancestors directive from each content-security-policy header, keeping the policy's other directives (such as base-uri 'self'). A header left with no directives is removed. Pipe through Shopifex.Plug.SetCSPHeader (the :shopify_embedded pipeline) afterwards to restrict framing to the Shopify admin.

Summary

Functions

call(conn, _)

init(options)