Skip to content

fix(csp): allow ask-trinity Cloud Function in connect-src (#1224)#1225

Merged
vybe merged 1 commit into
devfrom
feature/1224-help-chat-csp
Jun 16, 2026
Merged

fix(csp): allow ask-trinity Cloud Function in connect-src (#1224)#1225
vybe merged 1 commit into
devfrom
feature/1224-help-chat-csp

Conversation

@vybe

@vybe vybe commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The in-app Help chat (Ask Trinity) widget was fully non-functional under the production CSP: connect-src 'self' ws: wss: omitted the docs Q&A Cloud Function origin, so the browser blocked every fetch() with Refused to connect ... violates CSPTypeError: Failed to fetch.
  • Adds the specific Cloud Function origin (https://us-central1-mcp-server-project-455215.cloudfunctions.net) to connect-src in both CSP sources — narrow allowlist, no wildcard, no public-surface expansion (already a documented public endpoint).

Changes

  • src/frontend/security-headers.conf — prod nginx CSP connect-src
  • src/frontend/vite.config.js — dev-server CSP connect-src (mirrors prod)

Test Plan

  • ws:/wss: still present in both files — WebSocket real-time delivery unaffected
  • Allowlisted origin exactly matches the widget's hardcoded ENDPOINT (no drift)
  • CORS preflight verified: OPTIONS204 with Access-Control-Allow-Origin: *, Access-Control-Allow-Methods: POST, OPTIONS, Access-Control-Allow-Headers: Content-Type — no follow-on CORS blocker
  • Endpoint answers HTTP 200 to the widget's real {question} request schema
  • Manual: in a prod-style build, send a Help chat message → response renders, zero CSP violations in console

Fixes #1224

🤖 Generated with Claude Code

The in-app Help chat widget (HelpChatWidget.vue) fetches the public docs
Q&A Cloud Function, but the prod and dev Content-Security-Policy
connect-src directives only allowed 'self' ws: wss: — so the browser
blocked every request with "Refused to connect ... violates CSP" and the
widget failed with TypeError: Failed to fetch.

Add the specific Cloud Function origin (narrow allowlist, no wildcard) to
connect-src in both CSP sources:
- src/frontend/security-headers.conf (prod nginx)
- src/frontend/vite.config.js (dev server)

ws:/wss: preserved, so WebSocket real-time delivery is unaffected.
Verified the endpoint returns permissive CORS (ACAO: *, POST/OPTIONS,
Content-Type) and answers HTTP 200 to the widget's {question} schema, so
no CORS preflight surfaces as a follow-on blocker.

Fixes #1224

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vybe
vybe merged commit c52714b into dev Jun 16, 2026
13 of 14 checks passed
vybe added a commit that referenced this pull request Jun 16, 2026
) (#1226)

The in-app Help chat widget (HelpChatWidget.vue) fetches the public docs
Q&A Cloud Function, but the prod and dev Content-Security-Policy
connect-src directives only allowed 'self' ws: wss: — so the browser
blocked every request with "Refused to connect ... violates CSP" and the
widget failed with TypeError: Failed to fetch.

Add the specific Cloud Function origin (narrow allowlist, no wildcard) to
connect-src in both CSP sources:
- src/frontend/security-headers.conf (prod nginx)
- src/frontend/vite.config.js (dev server)

ws:/wss: preserved, so WebSocket real-time delivery is unaffected.
Verified the endpoint returns permissive CORS (ACAO: *, POST/OPTIONS,
Content-Type) and answers HTTP 200 to the widget's {question} schema, so
no CORS preflight surfaces as a follow-on blocker.

Fixes #1224

Co-authored-by: Eugene Vyborov <eugene@beingluminous.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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