Skip to content

Conversation

@reakaleek
Copy link
Member

@reakaleek reakaleek commented Oct 29, 2025

Problem

When using CloudFront with Origin Access Control (OAC) to secure Lambda Function URLs, POST requests require the x-amz-content-sha256 header for body integrity validation.

Solution

Added SHA256 hash computation in useFetchEventSource.ts for request body
Included x-amz-content-sha256 header in all POST requests to /ask-ai/stream
Used ES5-compatible hex formatting (avoiding padStart for broader browser support)

Why

Required by AWS CloudFront OAC to prove request body integrity from client to CloudFront. CloudFront handles the SigV4 signing; client only needs to compute the hash.
Impact: Enables secure streaming through CloudFront with OAC enabled, supporting the hybrid architecture for Lambda Function URLs.

@reakaleek reakaleek requested a review from a team as a code owner October 29, 2025 21:26
@reakaleek reakaleek requested a review from Mpdreamz October 29, 2025 21:26
@reakaleek reakaleek added the fix label Oct 29, 2025
@reakaleek reakaleek self-assigned this Oct 29, 2025
@reakaleek reakaleek merged commit 0e04b84 into main Oct 29, 2025
38 of 41 checks passed
@reakaleek reakaleek deleted the feature/x-amz-content-sha256 branch October 29, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants