Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Adjust secure headers for shared links to avoid breaking embeds (#5785)
Adrian Gruntkowskif6c6dec59e73
diff --git a/lib/plausible_web/plugs/secure_embed_headers.ex b/lib/plausible_web/plugs/secure_embed_headers.exnew file mode 100644index 0000000000..17f1745b4a--- /dev/null+++ b/lib/plausible_web/plugs/secure_embed_headers.ex@@ -0,0 +1,22 @@+defmodule PlausibleWeb.Plugs.SecureEmbedHeaders do+ @moduledoc """+ Sets secure headers tailored for embedded content.+ """++ import Plug.Conn++ def init(_opts) do+ []+ end++ def call(conn, _opts) do+ merge_resp_headers(+ conn,+ [+ {"referrer-policy", "strict-origin-when-cross-origin"},+ {"x-content-type-options", "nosniff"},+ {"x-permitted-cross-domain-policies", "none"}+ ]+ )+ end+enddiff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.exindex bc854c47cb..31f2f72e54 100644--- a/lib/plausible_web/router.ex+++ b/lib/plausible_web/router.ex@@ -35,7 +35,7 @@ defmodule PlausibleWeb.Router dopipeline :shared_link doplug :accepts, ["html"]- plug :put_secure_browser_headers+ plug PlausibleWeb.Plugs.SecureEmbedHeadersplug PlausibleWeb.Plugs.NoRobotsplug :put_root_layout, html: {PlausibleWeb.LayoutView, :app}end