Skip to content

fix(server): add CORS headers to handleChat error responses#24

Open
anfibiacreativa wants to merge 1 commit intomainfrom
fix/chat-cors-missing-headers
Open

fix(server): add CORS headers to handleChat error responses#24
anfibiacreativa wants to merge 1 commit intomainfrom
fix/chat-cors-missing-headers

Conversation

@anfibiacreativa
Copy link
Copy Markdown
Collaborator

The Invalid JSON (400) and Invalid request body (400) early-return paths in handleChat were missing CORS_HEADERS, unlike every other response in the file. A Zod validation failure (e.g. missing path in pageContext) would return a 400 without Access-Control-Allow-Origin, causing the browser to block the response entirely and surface a misleading CORS error.

Also relax PageContextSchema.path to optional (defaults to '') so a missing path never triggers a validation failure.

The Invalid JSON (400) and Invalid request body (400) early-return paths
in handleChat were missing CORS_HEADERS, unlike every other response in
the file. A Zod validation failure (e.g. missing path in pageContext) would
return a 400 without Access-Control-Allow-Origin, causing the browser to
block the response entirely and surface a misleading CORS error.

Also relax PageContextSchema.path to optional (defaults to '') so a
missing path never triggers a validation failure.
@anfibiacreativa anfibiacreativa requested a review from mhaack April 28, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant