App Engine deployment shows 'Configuration is not authorized' when using Vertex AI Search widget

I’m working on a Flask application that uses Vertex AI Search and I’m trying to get it running on Google App Engine. Everything seems to deploy fine, but when I try to use the search functionality, I get an authorization error.

Here’s my Flask setup:

app.py

from flask import Flask, render_template
import os

app = Flask(__name__)

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

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

search.html

<!DOCTYPE html>
<html lang="en">
  <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="a1b2c3d4-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      triggerId="searchButton">
    </gen-search-widget>

    <input placeholder="Enter search terms" id="searchButton" />
  </body>
</html>

app.yaml

runtime: python39

The application loads without issues, but when I click the search input field, it opens the search widget and then shows this error:

Configuration is not authorized on “myapp.uc.r.appspot.com

Has anyone encountered this before? I’m not sure what authorization settings I need to configure for this to work properly on App Engine.

yep, u gotta whitelist your app engine domain in the vertex ai search console. just go to the search config settings and add ur appspot.com url to the authorized domains list - that should fix the error.