"Configuration is not authorized" issue when using Vertex AI Search Widget in App Engine application

I’m working on a Flask web application that uses Google Cloud Vertex AI Search functionality and I’m trying to host it on App Engine. Everything seems to work fine locally, but when I deploy to App Engine, I run into authorization problems.

Here’s my basic Flask setup:

app.py

from flask import Flask, render_template, request
import os

web_app = Flask(__name__)

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

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

search.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Company Search Portal</title>
  </head>
  <body>
    <h2>Internal Document Search</h2>
    
    <script src="https://cloud.google.com/ai/gen-app-builder/client?hl=en_US"></script>

    <gen-search-widget
      configId="abc12345-yyyy-zzzz-wwww-def678901234"
      triggerId="searchButton">
    </gen-search-widget>

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

app.yaml

runtime: python39

The deployment works and the Flask app loads correctly. However, when I click on the search input field, it opens the Vertex AI search interface but shows this error message:

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

I have my Vertex AI search app properly configured with a datastore, but it seems like there’s some kind of domain authorization issue. Has anyone encountered this before? What permissions or configurations am I missing for App Engine deployment?

yeah, classic vertex ai search widget issue. whitelist your app engine domain in the vertex ai search config. go to search app settings and add your appspot.com domain to allowed origins. fixed it for me when i hit the same problem.