Skip to content

Commit aeb2e9f

Browse files
committed
middleware: Disable CSP for Svelte app for now
The Svelte app is using an inline script in the HTML file which includes the fingerprinted JS file paths, so we can't use a static hash of the script. We can figure these details out in the future.
1 parent 193be62 commit aeb2e9f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/middleware/common_headers.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub async fn add_common_headers(
3838
expires(&mut headers, 10 * ONE_YEAR);
3939
}
4040

41+
let is_svelte = path.starts_with("/svelte/");
42+
4143
let response = next.run(request).await;
4244

4345
headers.insert(header::ACCESS_CONTROL_ALLOW_ORIGIN, v("*"));
@@ -47,7 +49,10 @@ pub async fn add_common_headers(
4749
headers.insert(header::X_CONTENT_TYPE_OPTIONS, v("nosniff"));
4850
headers.insert(header::X_FRAME_OPTIONS, v("SAMEORIGIN"));
4951
headers.insert(header::X_XSS_PROTECTION, v("0"));
50-
if let Some(ref csp) = state.config.content_security_policy {
52+
if let Some(ref csp) = state.config.content_security_policy
53+
// TODO: CSP is disabled for the Svelte frontend for now
54+
&& !is_svelte
55+
{
5156
headers.insert(header::CONTENT_SECURITY_POLICY, csp.clone());
5257
}
5358
headers.insert(header::VARY, v("Accept, Accept-Encoding, Cookie"));

0 commit comments

Comments
 (0)