Skip to content

Commit 590e172

Browse files
committed
TNT-1615: Fix CSP Lambda error handling when fallback is provided
1 parent 9c821cc commit 590e172

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/short-ways-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aligent/cdk-static-hosting": patch
3+
---
4+
5+
Fix CSP Lambda error handling when fallback is provided

packages/static-hosting/lib/handlers/csp-lambda/origin-response.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ export const handler = async (
5555
// If no fallback was provided, throw the error and 500 response
5656
if (!FALLBACK_CSP) throw error;
5757

58+
// Use fallback CSP
59+
console.log("Using fallback CSP:", FALLBACK_CSP);
5860
response.headers["content-security-policy"] = [
5961
{ key: "Content-Security-Policy", value: FALLBACK_CSP },
6062
];
61-
throw error;
6263
}
6364

6465
return response;

0 commit comments

Comments
 (0)