如何使用“ http:// localhost:port/swagger-ui/index.html`html`html”将kong声明性(YAML)路由路径路由路径。

发布于 2025-02-09 05:42:22 字数 1127 浏览 3 评论 0原文

启动:端口8099具有Swagger UI,它应该是Kong的路线,但在通往Kong的路线时,输出是空的。

也许这是空白页面的原因:它试图获取Swagger的HTML和CSS等。

- host: host.docker.internal
  port: 8099
  name: swagger-service
  path: /swagger-ui/index.html
  routes:
  - name: swagger-service
    paths:
    - /swagger
    strip_path: true

我尝试写 https://docs.konghq.com /枢纽/石材付款/kong-plugin-url-urerite/但仍然空的

- host: host.docker.internal
  port: 8099
  name: swagger-service
  url: /swagger-ui/index.html
  routes:
    - name: swagger-service
      plugins:
      - name: kong-plugin-url-rewrite
        config: 
          url: http://swagger

8099端口 路由8099到Kong空页输出

Implematation: port 8099 has swagger ui which suppose to be route in kong but the output is empty when its route to kong.

Maybe this is the reason for blank page: its trying to get the html and css and etc. of the swagger.

- host: host.docker.internal
  port: 8099
  name: swagger-service
  path: /swagger-ui/index.html
  routes:
  - name: swagger-service
    paths:
    - /swagger
    strip_path: true

I tried re write https://docs.konghq.com/hub/stone-payments/kong-plugin-url-rewrite/ but still empty

- host: host.docker.internal
  port: 8099
  name: swagger-service
  url: /swagger-ui/index.html
  routes:
    - name: swagger-service
      plugins:
      - name: kong-plugin-url-rewrite
        config: 
          url: http://swagger

8099 port
8099 port
route 8099 to kong empty page output
route 8099 to kong

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

胡大本事 2025-02-16 05:42:22

这里的问题是,当您尝试访问Swagger URL时,Swagger会尝试使用相同的基本URL(由Kong暴露的)从模式URL获取模式,因此您将拥有404没有作为路线添加。
解决此问题的一种方法是添加模式URL作为路线,以便可以从招摇路线上访问。

The issue here is that when you try to access your swagger url, the swagger will try to fetch the schema from the schema url using the same base url (the one exposed by kong), hence you will have a 404 since the schma url is not added as a route.
A way to fix this is to add the schema url also as a route so that it can be accessible from your swagger route.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文