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 need 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

server.py

from flask import Flask, render_template
import os

app = Flask(__name__)

@app.route("/", methods=['GET', 'POST'])
def index():
    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="12b34567-abcd-efgh-ijkl-mnop890qrstu"
      triggerId="searchTrigger">
    </gen-search-widget>

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

app.yaml

runtime: python39

The Problem

When I click the search input field, it opens the Vertex AI search interface but shows this error:

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

How can I fix this authorization issue? Do I need to configure something specific for App Engine domains?

This auth error happens because Vertex AI Search validates which domains can make requests. Your domain needs to be on the authorized list.

Quick fix: add your App Engine domain to allowed origins in Vertex AI Search settings. But manually managing these configs gets messy fast with multiple environments.

I hit this same issue last year deploying across dev, staging, and prod. Rather than constantly updating domain lists, I automated the whole deployment pipeline.

My setup automatically updates Vertex AI config when I deploy anywhere new. It reads app.yaml, grabs the target domain, hits the Vertex AI API to update allowed origins, then triggers App Engine deployment. Zero manual work.

You can build this same automation with Latenode. It’s got Google Cloud connectors built-in and chains API calls, deployments, and config updates together. Way cleaner than doing it by hand.

Saves me 30 minutes per deployment and kills those auth errors completely.

had the same prob! you gotta add ur app engine domain as an allowed origin in the vertex ai config. just go to aai settings and whitelist myapp.uc.r.appspot.com. took me ages to find that out lol