Reputation: 93
I'm getting an Error 404 when trying to set my authorization key (key-auth) in the request header. I'm sure that there isn't any problem with my key because if I don't set it a Forbidden status will return.
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/
Upvotes: 1
Views: 1292
Reputation: 449
it should be key-auth
the problem is with indentation
- key-auth:
- proxy:
it must be on one level
basically this is an array:
policies: [{
'key-auth':null
},{
proxy:{ ... }
}]
this will fix the issue.
Upvotes: 3
Reputation: 24
Try removing the hyphen from key-auth
under policies:
in your config file - this worked for me. It should just be keyauth
.
Upvotes: 0