+-
使用域名访问swagger 一直提示Unable to infer base url.
首页 专栏 java 文章详情
0

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

氷落 发布于 3 月 3 日

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:

2. 情况说明

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

3. 百度过程遇到的坑

解决办法:在启动类上加上注解 @EnableSwagger2

被拦截

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

4. 问题排除过程

增加 EnableSwagger2 项目当中没有使用拦截

在页面使用F12查看报错

查看此ERR_CONTENT_LENGTH_MISMATCH说明

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

5. 有帮助的连接

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

java nginx swagger
阅读 32 发布于 3 月 3 日
收藏
分享
本作品系原创, 采用《署名-非商业性使用-禁止演绎 4.0 国际》许可协议
30岁程序员的挣扎之路
一个年过30,苦苦挣扎的程序员......
关注专栏
avatar
氷落

一个年过30,苦苦挣扎的程序员......

4 声望
0 粉丝
关注作者
0 条评论
得票 时间
提交评论
avatar
氷落

一个年过30,苦苦挣扎的程序员......

4 声望
0 粉丝
关注作者
宣传栏
目录

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:

2. 情况说明

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

3. 百度过程遇到的坑

解决办法:在启动类上加上注解 @EnableSwagger2

被拦截

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

4. 问题排除过程

增加 EnableSwagger2 项目当中没有使用拦截

在页面使用F12查看报错

查看此ERR_CONTENT_LENGTH_MISMATCH说明

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

5. 有帮助的连接

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