You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署GCP Vertex AI Agent至App Engine时遇‘配置未授权’错误

解决Vertex AI Agent Builder搜索Widget在App Engine的授权错误

使用GCP Vertex AI Agent Builder构建搜索应用并部署至App Engine后,应用可正常启动,但点击搜索输入框时触发以下错误:

Configuration is not authorized on "***.uc.r.appspot.com"

问题原因

Vertex AI搜索Widget的安全机制仅允许在预授权域名下加载应用配置,你的App Engine域名未被添加到授权列表,导致脚本拒绝加载配置。

解决方案

  1. 登录GCP控制台,进入Vertex AI Agent Builder的目标搜索应用管理界面
  2. 在应用配置页面找到授权域名设置项(对应你提供的搜索应用截图界面)
  3. 添加你的App Engine完整域名(例如xxx.uc.r.appspot.com,替换为实际域名)
  4. 保存配置,等待1-2分钟让设置生效
  5. 刷新App Engine应用页面,重新测试搜索功能

验证要点

  • 确认index.html中的configId与Vertex AI应用的配置ID完全匹配
  • 检查浏览器开发者工具的网络请求,确认Widget脚本https://cloud.google.com/ai/gen-app-builder/client?hl=en_US加载成功

应用代码参考

main.py

from flask import Flask, render_template
import os

app = Flask(__name__)


@app.route("/", methods=['POST', 'GET'])
def root():
    return render_template("index.html")


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 8080)), debug=True)

index.html

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="UTF-8">
    <title>TTC Intranet</title>
  </head>
  <body>
    <h1>TTC Intranet Search</h1>
    <!-- Widget JavaScript bundle -->
    <script src="https://cloud.google.com/ai/gen-app-builder/client?hl=en_US"></script>

    <!-- Search widget element is not visible by default -->
    <gen-search-widget
      configId="21a52013-xxxx-xxxx-xxxx-xxxx80a5xxxx"
      triggerId="searchWidgetTrigger">
    </gen-search-widget>

    <!-- Element that opens the widget on click. It does not have to be an input -->
    <input placeholder="Search here" id="searchWidgetTrigger" />
  </body>
</html>

app.yaml

runtime: python39

内容的提问来源于stack exchange,提问作者Santanu Ghosh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 07:00:14