You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by dj...@apache.org on 2026/10/10 02:23:10 UTC

(cloudberry-site) branch main updated: Fix kapa.ai widget blocked by the ASF default CSP

This is an automated email from the ASF dual-hosted git repository.

tuhaihe pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry-site.git


The following commit(s) were added to refs/heads/main by this push:
     new b8e53d2b07 Fix kapa.ai widget blocked by the ASF default CSP
b8e53d2b07 is described below

commit b8e53d2b07add02bd59c1fb51da492d920002319
Author: Dianjin Wang <wa...@gmail.com>
AuthorDate: Fri Oct 2 19:29:50 2026 +0800

    Fix kapa.ai widget blocked by the ASF default CSP
    
    The kapa.ai "Ask AI" widget never shows up on cloudberry.apache.org.
    ASF infra serves every *.apache.org site with a default
    Content-Security-Policy whose script-src only allows *.apache.org and
    a few other hosts, so the browser refuses to load
    https://widget.kapa.ai/kapa-widget.bundle.js. The local dev server
    sends no CSP, which is why it worked there.
    
    Add static/.htaccess to override the policy, the same way the Apache
    Doris website does. It keeps the ASF default sources except the Scarf
    host, which this site does not use, and adds what the widget needs:
    
    - script-src: widget.kapa.ai and hCaptcha
    - connect-src: proxy.kapa.ai, metrics.kapa.ai, Kapa's Cloud Run proxy
      and hCaptcha
    - style-src and frame-src: hCaptcha
    
    Docusaurus copies static/.htaccess into build/, so it is published to
    asf-site with the rest of the site.
    
    See: Issue#401 <https://github.com/apache/cloudberry-site/issues/401>
    
    Assisted-by: Claude Code
---
 static/.htaccess | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/static/.htaccess b/static/.htaccess
new file mode 100644
index 0000000000..737cb48d09
--- /dev/null
+++ b/static/.htaccess
@@ -0,0 +1,37 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Content-Security-Policy for cloudberry.apache.org.
+#
+# ASF infra sends a default policy that only allows *.apache.org and a few
+# other hosts. Setting the header here replaces it entirely, so the policy
+# below keeps the ASF default sources (*.apache.org covers Matomo on
+# analytics.apache.org) and adds the hosts the kapa.ai "Ask AI" widget needs.
+# The ASF default's Scarf host is left out because nothing here uses Scarf.
+#
+#   script-src   https://widget.kapa.ai (the widget), hCaptcha
+#   connect-src  https://proxy.kapa.ai, https://metrics.kapa.ai and Kapa's
+#                Cloud Run proxy (the chat API), hCaptcha
+#   style-src    hCaptcha
+#   frame-src    hCaptcha (the challenge iframe)
+#
+# When adding another third-party service, append its hosts to the matching
+# directive(s) below. The policy must stay on one line: .htaccess cannot use
+# Define, and Apache has no string concatenation.
+<IfModule mod_headers.c>
+    Header set Content-Security-Policy "default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://www.apachecon.com/ https://www.communityovercode.org/ https://*.apache.org/ https://apache.org/; script-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://www.apachecon.com/ https://www.communityovercode.org/ https://*.apache.org/ https://apache.org/ https://widget.kapa.ai https://hcaptcha.com https://*.hcaptcha.com; connect-src 'self' data: blob: 'unsafe-inline' 'unsafe [...]
+</IfModule>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org