首页 > 解决方案 > 在应用程序配置中找不到 URLMap 条目

问题描述

我正在尝试按照以下链接 https://cloud.google.com/appengine/docs/standard/nodejs/quickstart上的说明将 node.js 应用程序部署到 Google App Engine Standard

部署时出现以下错误

C:\Code\NodeJS\nodejs-docs-samples\appengine\hello-world\standard (master)
λ gcloud app deploy
ERROR: (gcloud.app.deploy) An error occurred while parsing file: [C:\Code\NodeJS\nodejs-docs-samples\appengine\hello-world\standard\app.yaml]
No URLMap entries found in application configuration
  in "C:\Code\NodeJS\nodejs-docs-samples\appengine\hello-world\standard\app.yaml", line 17, column 1

app.yaml 文件内容如下:

# Copyright 2017, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START app_yaml]
runtime: nodejs8
# [END app_yaml]

~

标签: node.jsgoogle-app-engine

解决方案


与您的应用程序本身负责将请求 URL 映射到处理程序的灵活环境不同,在标准环境中,这需要在app.yaml文件中进行配置,以便 GAE 知道这种映射。从Handlers 元素(浏览该部分中的整个表格,标准环境中的新表格):

handlers元素提供了一个 URL 模式列表以及如何处理它们的描述。App Engine 可以通过执行应用程序代码或提供随代码上传的静态文件(例如图像、CSS 或 JavaScript)来处理 URL。

模式按照它们在app.yaml 文件中出现的顺序从上到下进行评估。模式与 URL 匹配的第一个映射是用于处理请求的映射。

您需要做的就是为您的应用程序提供至少一个这样的 URL 处理程序映射。


推荐阅读