部署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域名未被添加到授权列表,导致脚本拒绝加载配置。
解决方案
- 登录GCP控制台,进入Vertex AI Agent Builder的目标搜索应用管理界面
- 在应用配置页面找到授权域名设置项(对应你提供的搜索应用截图界面)
- 添加你的App Engine完整域名(例如
xxx.uc.r.appspot.com,替换为实际域名) - 保存配置,等待1-2分钟让设置生效
- 刷新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
相关产品推荐
相关产品推荐

