在应用程序配置中找不到URLMap条目

时间:2018-06-13 16:22:54

标签: node.js google-app-engine

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

部署时出现以下错误

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]

2 个答案:

答案 0 :(得分:2)

与应用程序本身负责将请求URL映射到处理程序的灵活环境不同,在标准环境中,这需要在app.yaml文件中进行配置,以便GAE知道此类映射。来自Handlers element(通过该部分的整个表格,标准环境中的新内容):

  

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

     

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

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

答案 1 :(得分:0)

Dan's answer使我步入正轨。

为了后人,这是一个示例app.yaml文件,用于解决该错误消息:

runtime: nodejs8
handlers:
- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto