使用域名访问swagger 一直提示Unable to infer base url.

1. 错误提示

Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://example.org/api/v2/api... then the base url is http://example.org/api/. Please enter the location manually:html

2. 状况说明

  1. 使用IP访问localhost:8080/api/swagger-ui.html 没有问题
  2. 使用nginx映射之后,访问https://www.xxxxx.com/api/swa... 开始出现问题

3. 百度过程遇到的坑

  1. 解决办法:在启动类上加上注解@EnableSwagger2
  2. 被拦截nginx

    /swagger-ui.html
    /webjars/**
    /v2/**
    /swagger-resources/**

4. 问题排除过程

  1. 增长EnableSwagger2
  2. 项目当中没有使用拦截
  3. 在页面使用F12查看报错web

    1. image
  4. 查看此ERR_CONTENT_LENGTH_MISMATCH说明api

    1. 发现貌似是nginx问题
  5. 查看nginx错误日志
  6. 发现proxy_temp目录没有权限
  7. 偷懒赋予777权限

5. 有帮助的链接

https://blog.csdn.net/mr_ooo/...ui

相关文章
相关标签/搜索