I’m working on a Flask application that uses Vertex AI Agent Builder for search functionality and want to deploy it to Google App Engine. Everything works fine locally, but when I deploy to App Engine I get an authorization error.
My Flask application structure:
server.py
from flask import Flask, render_template
import os
web_app = Flask(__name__)
@web_app.route("/", methods=['GET', 'POST'])
def home():
return render_template("search.html")
if __name__ == '__main__':
web_app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 8080)), debug=True)
search.html
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Company Search Portal</title>
</head>
<body>
<h1>Internal Document Search</h1>
<script src="https://cloud.google.com/ai/gen-app-builder/client?hl=en_US"></script>
<gen-search-widget
configId="42b73024-yyyy-yyyy-yyyy-yyyy91b6yyyy"
triggerId="searchTrigger">
</gen-search-widget>
<input placeholder="Enter search terms" id="searchTrigger" />
</body>
</html>
app.yaml
runtime: python39
The Flask app starts successfully on App Engine. When I click the search input field, it opens the Vertex AI search interface correctly. However, as soon as I try to perform a search, I get this error message:
Configuration is not authorized on “my-project.uc.r.appspot.com”
I’ve set up my Vertex AI search engine and datastore properly in the console. The search widget works perfectly when testing locally. What configuration steps am I missing for the App Engine deployment? Do I need to add specific permissions or modify the app.yaml file?