我正在使用Cloud Run,Endpoints和Cloud Functions构建API服务。有多个端点可以完全正常运行,但是我不再能够部署任何新端点。
Cloud Run环境发生错误,导致它无法调用相应的Cloud Function。奇怪的是,所有其他端点都可以正常工作,但是我无法创建新端点。
我找到了这篇文章:https://cloud.google.com/endpoints/docs/openapi/troubleshoot-response-errors,但这仅适用于BAD_GATEWAY错误代码。 所有代码都已完全部署好。部署Cloud Function,Cloud Run或Open API yaml文件时没有错误。
响应错误:
{
"code": 13,
"message": "INTERNAL_SERVER_ERROR",
"details": [
{
"@type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "application"
}
]
}
Cloud Run中的错误:
5#5: *33 invalid URL prefix in "", client: xxxxx, server: , request: "GET /user HTTP/1.1", host: "[my cloud run host]"
GET 500 404 B4 ms python-requests/2.22.0 [cloud run host]/user
main.py文件:
def user(request):
return "Ok"
yaml文件:
/user:
x-google-backend:
address: https://[cloud functions host]/user
get:
summary: Retrieves a user.
operationId: getUser
responses:
'200':
description: A successful response
'400':
description: BAD_REQUEST
答案 0 :(得分:0)
如果我们查看您的YAML:
/user:
x-google-backend:
address: https://[cloud functions host]/user
get:
summary: Retrieves a user.
operationId: getUser
responses:
'200':
description: A successful response
'400':
description: BAD_REQUEST
...特别注意x-google-backend
部分。请注意,该路径在/user
路径段内 中。现在注意,该地址是带有路径的URL 。您不需要URL中的路径部分,而只需要主机的地址(和可选端口)。将您的YAML开头更改为:
/user:
x-google-backend:
address: https://[cloud functions host]
(/user
部分已从address
行中删除)