mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 21:29:02 +08:00
fix(swagger): 使用相对地址避免跨域
This commit is contained in:
1 parent
41f20b2db3
commit
75f426deb3
4 files changed
+4
-9
No files matched your search
@@ -34,4 +34,4 @@ jasypt:
|
||||
|
||||
# swagger token url 配置
|
||||
swagger:
|
||||
token-url: ${swagger.gateway}/admin/oauth2/token
|
||||
token-url: ${server.servlet.context-path}/oauth2/token
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.common.swagger.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.pig4cloud.pigx.common.swagger.support.SwaggerProperties;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
@@ -79,7 +80,7 @@ public class OpenAPIDefinition extends OpenAPI implements InitializingBean, Appl
|
||||
this.schemaRequirement(HttpHeaders.AUTHORIZATION, this.securityScheme(swaggerProperties));
|
||||
// servers
|
||||
List<Server> serverList = new ArrayList<>();
|
||||
serverList.add(new Server().url(swaggerProperties.getGateway() + "/" + path));
|
||||
serverList.add(new Server().url(StrUtil.SLASH + path));
|
||||
this.servers(serverList);
|
||||
// 支持参数平铺
|
||||
SpringDocUtils.getConfig().addSimpleTypesForParameterObject(Class.class);
|
||||
|
||||
-5
@@ -63,11 +63,6 @@ public class SwaggerProperties {
|
||||
**/
|
||||
private String title = "";
|
||||
|
||||
/**
|
||||
* 网关
|
||||
*/
|
||||
private String gateway;
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
swagger:
|
||||
enabled: true
|
||||
title: PigX Swagger API
|
||||
gateway: http://${GATEWAY-HOST:pigx-gateway}:${GATEWAY-PORT:9999}
|
||||
token-url: ${swagger.gateway}/auth/oauth2/token
|
||||
token-url: /auth/oauth2/token
|
||||
scope: server
|
||||
Reference in new issue
Block a user