Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: disable x frame options header on Hugging Face (#4558)

Marc Klingenba5c1cd70e50
diff --git a/web/next.config.mjs b/web/next.config.mjs
index 662014bb02..9cc0590f38 100644
--- a/web/next.config.mjs
+++ b/web/next.config.mjs
@@ -28,6 +28,9 @@ const cspHeader = `
${env.SENTRY_CSP_REPORT_URI ? `report-uri ${env.SENTRY_CSP_REPORT_URI}; report-to csp-endpoint;` : ""}
`;
+// Match rules for Hugging Face
+const huggingFaceHosts = ["huggingface.co", ".*\\.hf\\.space$"];
+
const reportToHeader = {
key: "Report-To",
value: JSON.stringify({
@@ -78,10 +81,6 @@ const nextConfig = {
{
source: "/:path*",
headers: [
- {
- key: "x-frame-options",
- value: "SAMEORIGIN",
- },
{
key: "X-Content-Type-Options",
value: "nosniff",
@@ -97,6 +96,20 @@ const nextConfig = {
...(env.SENTRY_CSP_REPORT_URI ? [reportToHeader] : []),
],
},
+ {
+ source: "/:path*",
+ headers: [
+ {
+ key: "x-frame-options",
+ value: "SAMEORIGIN",
+ },
+ ],
+ // Disable x-frame-options on Hugging Face to allow for embedded use of Langfuse
+ missing: huggingFaceHosts.map((host) => ({
+ type: "host",
+ value: host,
+ })),
+ },
// CSP header
{
source: "/:path((?!api).*)*",
@@ -107,16 +120,10 @@ const nextConfig = {
},
],
// Disable CSP on Hugging Face to allow for embedded use of Langfuse
- missing: [
- {
- type: "host",
- value: "huggingface.co",
- },
- {
- type: "host",
- value: ".*\\.hf\\.space$", // *.hf.space
- },
- ],
+ missing: huggingFaceHosts.map((host) => ({
+ type: "host",
+ value: host,
+ })),
},
// Required to check authentication status from langfuse.com
...(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined