[英]Express-Gateway response error after setting authorization
I'm getting an Error 404 when trying to set my authorization key (key-auth) in the request header. 我在尝试在请求标头中设置我的授权密钥(key-auth)时收到错误404。 I'm sure that there isn't any problem with my key because if I don't set it a Forbidden status will return.
我确定我的密钥没有任何问题,因为如果我没有设置它,Forbidden状态将返回。
before setting any credentials: 在设置任何凭据之前:
$ curl http://localhost:8080/ip
will return: 将返回:
{
"origin": "5.116.28.133"
}
after creating a key-auth credential: 创建密钥身份验证凭据后:
$ curl -H "Authorization: apiKey ${keyId}:${keySecret}" http://localhost:8080/ip
will return: 将返回:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /ip</pre>
</body>
</html>
and it's my gateway config: 这是我的网关配置:
http:
port: 8080
admin:
port: 9876
hostname: localhost
apiEndpoints:
api:
host: localhost
paths: '/ip'
serviceEndpoints:
httpbin:
url: 'https://httpbin.org'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
- name: default
apiEndpoints:
- api
policies:
- key-auth:
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true
Does anyone know why this issue happens? 有谁知道为什么会出现这个问题?
find more information about express-gateway from http://www.express-gateway.io/ 有关Express-gateway的更多信息, 请访问http://www.express-gateway.io/
it should be key-auth
the problem is with indentation 它应该是
key-auth
问题是缩进
- key-auth:
- proxy:
it must be on one level 它必须在一个层面上
basically this is an array: 基本上这是一个数组:
policies: [{
'key-auth':null
},{
proxy:{ ... }
}]
this will fix the issue. 这将解决问题。
Try removing the hyphen from key-auth
under policies:
in your config file - this worked for me. 尝试从
policies:
下的key-auth
删除连字符policies:
在配置文件中 - 这对我有用。 It should just be keyauth
. 它应该是
keyauth
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.