【发布时间】:2020-01-20 05:25:50
【问题描述】:
我已经设置了指向 Google Functions 的 Google Cloud 端点 (open-api.yaml)。我已经使用 Google Cloud Run 创建了 API Gateway 服务器。我测试了同样的,发现它工作正常。
在 YAML 和 Google 函数中进行了一些更新后,我现在收到 错误:无法处理请求。这是服务器 500 错误。 YAML文件如下:
swagger: '2.0'
info:
title: API gateway
description: Gateway on Cloud Endpoints with a Google Cloud Functions backend
version: 1.0.0
host: xxxx-service-abcd-uc.a.run.app
schemes:
- https
produces:
- application/json
paths:
/auth/signup:
post:
summary: Create a new user
operationId: authSignup
x-google-backend:
address: https://us-central1-project-id.cloudfunctions.net/api-auth-function
path_translation: APPEND_PATH_TO_ADDRESS
responses:
'200':
description: A successful response
schema:
type: string
/auth/login:
post:
summary: Logs in an existing user
operationId: authLogin
x-google-backend:
address: https://us-central1-project-id.cloudfunctions.net/api-auth-function
path_translation: APPEND_PATH_TO_ADDRESS
responses:
'200':
description: A successful response
schema:
type: string
/auth/check:
get:
summary: check
operationId: authCheck
x-google-backend:
address: https://us-central1-project-id.cloudfunctions.net/api-auth-function
path_translation: APPEND_PATH_TO_ADDRESS
responses:
'200':
description: A successful response
schema:
type: string
当我通过 Postman 的 post 调用调用 url:https://xxx--service-abcd-uc.a.run.app/auth/login 或使用 Postman 或浏览器的 get 调用 https://xxxx-service-abcd-uc.a.run.app/auth/check 时,我收到此错误。
Google Cloud Run 上的日志只有以下条目:
GET 500 700 B 184 msChrome 79 https://xxxx-service-abcd-uc.a.run.app/auth/check
或
POST 500 622 B 99 PostmanRuntime/7.22.0 https://xxxx-service-abcd-uc.a.run.app/auth/login
由于它是早期工作的,所以肯定有一些我无法检测到的愚蠢错误。感谢您的帮助。
【问题讨论】:
-
如果我理解正确,您提供了一个由 Cloud Run 执行的 Docker 容器。如果你直接定位它,它会起作用吗?
-
感谢@Kolban 的回复。是的,我使用了 Google 文档建议的容器来运行端点。当我调用 Google Run url 时,它给了我同样的错误。请注意,在日志中,我使用 Postman 和 Chrome 浏览器方法直接调用 Post 和 Get 路由。我检查的谷歌功能有效
-
我承认我昨天让它工作了......只是做了一些改变。因此,我怀疑我在 yaml 中搞砸了一些事情
标签: google-cloud-run google-cloud-endpoints-v2