diff --git a/kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java b/kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java index 4103f92..0293b85 100644 --- a/kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java +++ b/kq-vas-api/src/main/java/com/ningdatech/kqapi/security/config/RedisSessionConfig.java @@ -34,6 +34,9 @@ public class RedisSessionConfig { @Value("${nd.cache.def.keyPrefix:}") private String keyPrefix; + @Value("${cookie.path}") + private String cookiePath; + public String getRedisNamespace() { return (StrUtil.isBlank(keyPrefix) ? StrPool.EMPTY : keyPrefix + StrPool.COLON) + RedisIndexedSessionRepository.DEFAULT_NAMESPACE; } @@ -45,6 +48,7 @@ public class RedisSessionConfig { // 创建 DefaultCookieSerializer 对象 DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer(); cookieSerializer.setCookieName(BizConst.COOKIE_KEY); + cookieSerializer.setCookiePath(cookiePath); cookieSerializer.setCookieMaxAge(AuthConst.SESSION_TIME_SECONDS); // 设置到 sessionIdResolver 中 sessionIdResolver.setCookieSerializer(cookieSerializer); diff --git a/kq-vas-api/src/main/resources/application-dev.yml b/kq-vas-api/src/main/resources/application-dev.yml index 03e653a..a458a40 100644 --- a/kq-vas-api/src/main/resources/application-dev.yml +++ b/kq-vas-api/src/main/resources/application-dev.yml @@ -4,6 +4,9 @@ server: context-path: /kq shutdown: graceful +cookie: + path: ${server.servlet.context-path} + spring: mvc: pathmatch: diff --git a/kq-vas-api/src/main/resources/application-pre.yml b/kq-vas-api/src/main/resources/application-pre.yml index 137cf86..c2b463b 100644 --- a/kq-vas-api/src/main/resources/application-pre.yml +++ b/kq-vas-api/src/main/resources/application-pre.yml @@ -4,6 +4,9 @@ server: context-path: /kq shutdown: graceful +cookie: + path: /dev/kq + spring: mvc: pathmatch: diff --git a/kq-vas-api/src/main/resources/application-prod.yml b/kq-vas-api/src/main/resources/application-prod.yml index b4d1386..8d96540 100644 --- a/kq-vas-api/src/main/resources/application-prod.yml +++ b/kq-vas-api/src/main/resources/application-prod.yml @@ -4,6 +4,9 @@ server: context-path: /kq shutdown: graceful +cookie: + path: ${server.servlet.context-path} + spring: mvc: pathmatch: