简体   繁体   English

设置授权后,Express-Gateway响应错误

[英]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.

相关问题 在express-gateway中找不到模块users.json错误 - Can not find module users.json error in express-gateway 覆盖快速网关配置 - Override express-gateway config Express-gateway 为快速微服务应用程序创建新的插件/策略 - Express-gateway create new plugin / policy for express microservices application 如何在快速网关中设置proxyTimeout? - How can I set proxyTimeout in express-gateway? 有没有一种简单的方法可以从 express-gateway 服务生成 API 文档? - Is there a simple way to generate API documentation from express-gateway services? 如何正确使用express-gateway对Web应用程序进行身份验证? - How to properly use express-gateway for authentication of a web app? 我无法在 Express-Gateway 上访问我想要的数据 - I cannot access the data I want on Express-Gateway Express-Gateway - 带有 docker-compose Nodejs 微服务架构的 502 错误网关 - Express-Gateway - 502 Bad Gateway with docker-compose Nodejs Microservices Architecture 使用 Ingress 服务类型将“express-gateway”部署到 Google Kubernetes 引擎时出现问题 - Problem deploying “express-gateway” to Google Kubernetes Engine with Ingress service type 响应后在Express JS中进行错误处理 - Error handling in Express JS after response
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM