尝试在请求标头中设置我的授权密钥 (key-auth) 时出现错误 404。我确定我的密钥没有任何问题,因为如果我不设置它,就会返回禁止状态。
在设置任何凭据之前:
$ curl http://localhost:8080/ip
将返回:
{
"origin": "5.116.28.133"
}
创建密钥身份验证凭据后:
$ curl -H "Authorization: apiKey ${keyId}:${keySecret}" http://localhost:8080/ip
将返回:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /ip</pre>
</body>
</html>
这是我的网关配置:
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
有谁知道为什么会发生这个问题?
从http://www.express-gateway.io/查找有关 express-gateway 的更多信息