Skip to content

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

fix(web): allow storage upload URLs in CSP (#14665)

Tobias Wochinger3eb70e614ee7
diff --git a/web/next.config.mjs b/web/next.config.mjs
index dc7a020cd6..5e841ad0a9 100644
--- a/web/next.config.mjs
+++ b/web/next.config.mjs
@@ -11,7 +11,9 @@ import { env } from "./src/env.mjs";
* img-src https to allow loading images from SSO providers
*/
// Dataset attachments PUT media directly to presigned storage URLs, so
-// connect-src must allow AWS S3 and the configured S3-compatible endpoint.
+// connect-src must allow AWS S3, Azure Blob Storage, GCS, and the configured
+// S3-compatible endpoint. The endpoint env var is only present at runtime in
+// official Docker images, so static wildcards cover the common providers too.
const mediaUploadConnectSrc = (() => {
const endpoint = env.LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT;
if (!endpoint) return "";
@@ -35,7 +37,7 @@ const cspHeader = `
base-uri 'self';
form-action 'self' https://login.microsoftonline.com https://login.microsoft.com https://*.microsoftonline.com;
frame-ancestors 'none';
- connect-src 'self' ${mediaUploadConnectSrc}https://*.langfuse.com https://*.langfuse.dev https://*.ingest.us.sentry.io https://*.sentry.io https://chat.uk.plain.com https://*.amazonaws.com https://prod-uk-services-attachm-attachmentsuploadbucket2-1l2e4906o2asm.s3.eu-west-2.amazonaws.com https://login.microsoftonline.com https://login.microsoft.com https://*.microsoftonline.com https://graph.microsoft.com;
+ connect-src 'self' ${mediaUploadConnectSrc}https://*.langfuse.com https://*.langfuse.dev https://*.ingest.us.sentry.io https://*.sentry.io https://chat.uk.plain.com https://*.amazonaws.com https://*.blob.core.windows.net https://storage.googleapis.com https://prod-uk-services-attachm-attachmentsuploadbucket2-1l2e4906o2asm.s3.eu-west-2.amazonaws.com https://login.microsoftonline.com https://login.microsoft.com https://*.microsoftonline.com https://graph.microsoft.com;
media-src 'self' https: http://localhost:*;
${env.LANGFUSE_CSP_ENFORCE_HTTPS === "true" ? "upgrade-insecure-requests; block-all-mixed-content;" : ""}
${env.SENTRY_CSP_REPORT_URI ? `report-uri ${env.SENTRY_CSP_REPORT_URI}; report-to csp-endpoint;` : ""}