Skip to content

[website] Allow Kapa AI Widget Resources on Fluss Website#3209

Closed
Kaixuan-Duan wants to merge 2 commits intoapache:mainfrom
Kaixuan-Duan:fix/3206-askai-csp-kapa
Closed

[website] Allow Kapa AI Widget Resources on Fluss Website#3209
Kaixuan-Duan wants to merge 2 commits intoapache:mainfrom
Kaixuan-Duan:fix/3206-askai-csp-kapa

Conversation

@Kaixuan-Duan
Copy link
Copy Markdown

@Kaixuan-Duan Kaixuan-Duan commented Apr 26, 2026

Purpose

Linked issue: close #3206

Brief change log

website/.htaccess: append to CSP_PROJECT_DOMAINS only the precise hosts listed in Kapa's documentation
(https://docs.kapa.ai/integrations/faq#how-do-i-fix-csp-errors), plus the two reCAPTCHA hosts the widget loads at runtime:

Domain Why it is needed Source
https://widget.kapa.ai Widget bundle (kapa-widget.bundle.js) Kapa CSP guide
https://proxy.kapa.ai Primary chat / search backend Kapa CSP guide
https://kapa-widget-proxy-la7dkmplpq-uc.a.run.app Cloud Run fallback (3 endpoints in the bundle) Kapa CSP guide
https://metrics.kapa.ai Widget telemetry Kapa CSP guide
https://www.google.com/recaptcha/ reCAPTCHA Enterprise loader Kapa CSP guide + verified in bundle
https://www.gstatic.com/recaptcha/ reCAPTCHA companion resources (recaptcha__<lang>.js) Verified by curl enterprise.js (loaded transitively)
https://hcaptcha.com hCaptcha challenge Kapa CSP guide
https://*.hcaptcha.com hCaptcha sub-resources (vendor apex only) Kapa CSP guide

No cross-tenant wildcard is used.

Tests

This is an .htaccess-only change with no executable code path, so there is nothing to add to the JUnit suite.

API and Format

No. Website / CSP configuration only.

Documentation

No. User-visible behavior is that the existing "Ask AI" button starts working.

Fixes apache#3206

The "Ask AI" button on https://fluss.apache.org/ relies on the Kapa AI
widget, but the ASF infra default Content-Security-Policy blocks all of
its resources, so the widget never loads.

This change adds the domains the widget actually contacts to the
CSP_PROJECT_DOMAINS allowlist in website/.htaccess (which the ASF
infra-side httpd config injects into default-src / script-src /
style-src / frame-src):

  * https://*.kapa.ai/                - widget bundle and assets
                                        (widget.kapa.ai)
  * https://www.google.com/recaptcha/ - Google reCAPTCHA Enterprise,
  * https://www.gstatic.com/recaptcha/  loaded by the widget for
                                        anti-bot verification of
                                        feedback submissions
  * https://*.a.run.app               - Kapa chat-stream backend proxy,
                                        hosted on Google Cloud Run
                                        (kapa-widget-proxy-*.a.run.app)

Locally verified with a meta-CSP-equivalent test page
(target/kapa-test.html served over http://localhost): the widget bundle
loads, reCAPTCHA Enterprise loads, and the chat-stream proxy request is
no longer blocked by CSP.
Copy link
Copy Markdown
Contributor

@binary-signal binary-signal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this domain is needed for https://*.a.run.app looks suspicious

@Kaixuan-Duan
Copy link
Copy Markdown
Author

Fair concern. *.a.run.app is Google Cloud Run's default host suffix (owned by Google, not a third party); it's needed for connect-src because the Kapa widget's chat backend runs there as kapa-widget-proxy--uc.a.run.app — without it the widget loads but every question silently fails.

@polyzos
Copy link
Copy Markdown
Contributor

polyzos commented Apr 27, 2026

@wuchong @MehulBatra can you take a look? or should we revert #3209 first and coordinate with the security team as Jark pointed out?

@Kaixuan-Duan
Copy link
Copy Markdown
Author

@binary-signal @polyzos thanks for pushing back on this — you were right to flag the wildcards, and I'm sorry for the noise of the first revision.

Kapa publishes an official CSP guide listing the exact hosts the widget needs: https://docs.kapa.ai/integrations/faq#how-do-i-fix-csp-errors

I cross-checked the bundle's runtime hosts against that list — they match exactly. The wildcards (*.kapa.ai/ and *.a.run.app) are now replaced with the precise host list from the guide.

PR description updated. Could you take another look when you have a moment? Happy to tighten further if anything still looks off.

cc @wuchong @MehulBatra

@MehulBatra
Copy link
Copy Markdown
Contributor

Hi @Kaixuan-Duan thank you for the great work, but due to certain policies we cannot enable the third party AI agent on fluss website, I am working on getting that resolved, for the time being I am going to close this, we can get back to this later.

@MehulBatra MehulBatra closed this Apr 27, 2026
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.

[docs] AskAi fails to load on Fluss website

4 participants