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

Issue Description

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

My Setup

Here’s my Flask application code:

server.py

from flask import Flask, render_template
import os

server = Flask(__name__)

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

if __name__ == '__main__':
    server.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 Search System</h1>
    <script src="https://cloud.google.com/ai/gen-app-builder/client?hl=en_US"></script>
    
    <gen-search-widget
      configId="34b71024-yyyy-yyyy-yyyy-yyyy91c6yyyy"
      triggerId="searchTrigger">
    </gen-search-widget>
    
    <input placeholder="Enter search query" id="searchTrigger" />
  </body>
</html>

app.yaml

runtime: python39

The Problem

When I deploy this to App Engine and try to use the search widget, I get this error message:

Configuration is not authorized on “***.uc.r.appspot.com”

The app loads fine and the search input appears, but clicking on it to trigger the search widget results in this authorization error. Has anyone encountered this issue before? What am I missing in my configuration?

I’ve hit this exact problem deploying search widgets to App Engine. Vertex AI Search needs to whitelist your App Engine domain.

In Google Cloud Console, find your Vertex AI Search app. Go to “Configurations” then “Advanced Settings” or “Allowed Domains”. Add your App Engine URL there.

Add both:

  • https://YOUR-PROJECT-ID.uc.r.appspot.com
  • YOUR-PROJECT-ID.uc.r.appspot.com

Changes take a few minutes to kick in. Also check your App Engine service account has the right Vertex AI Search permissions.

I also had to enable the Discovery Engine API. The error’s pretty generic but it’s usually a domain authorization issue.