【发布时间】:2018-11-08 07:32:51
【问题描述】:
尝试向服务器发送 OPTIONS 时出错。 错误:
{
"code": 7,
"message": "The service does not allow CORS traffic.",
"details": [
{
"@type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "service_control"
}
]
}
如果我发送 GET 请求(通过邮递员),我会得到正常响应。
节点服务器使用启用了 cors 的 KOA.js
app.use(cors());
它可以在没有端点的情况下工作,所以我认为服务器不会有问题。
app.yaml
runtime: nodejs
env: flex
env_variables:
NODE_ENV: "dev"
handlers:
- url: /
static_dir: /
http_headers:
Access-Control-Allow-Origin: '*'
endpoints_api_service:
name: ******.appspot.com
rollout_strategy: managed
openapi-appengine.yaml
swagger: "2.0"
info:
description: "A simple Google Cloud Endpoints API example."
title: "Endpoints Example"
version: "1.0.0"
host: "******.appspot.com"
x-google-endpoints:
- name: "******.appspot.com"
allowCors: "true"
x-google-allow: all
paths:
/api/user:
get:
operationId: "getcurrentuser"
produces:
- "application/json"
parameters: []
responses:
200:
description: "successful operation"
schema:
type: "object"
security:
- firebase: []
securityDefinitions:
firebase:
authorizationUrl: ""
flow: "implicit"
type: "oauth2"
x-google-issuer: "https://securetoken.google.com/******"
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
x-google-audiences: "******,******"
【问题讨论】:
-
您找到解决方案了吗?
-
@FrancescoClementi 是的,我在“x-google-audiences”中添加了错误的数据。
标签: firebase google-app-engine cors google-cloud-endpoints