mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
chore: 配置调整
This commit is contained in:
parent
a02cb83cff
commit
2c1b8054e7
@ -1,6 +1,7 @@
|
||||
package io.github.xxyopen.novel.core.config;
|
||||
|
||||
import io.github.xxyopen.novel.core.constant.SystemConfigConsts;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
@ -14,13 +15,19 @@ import org.springframework.web.filter.CorsFilter;
|
||||
* @date 2022/5/13
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(CorsProperties.class)
|
||||
@RequiredArgsConstructor
|
||||
public class CorsConfig {
|
||||
|
||||
private final CorsProperties corsProperties;
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
// 允许的域,不要写*,否则cookie就无法使用了
|
||||
config.addAllowedOrigin(SystemConfigConsts.NOVEL_FRONT_WEB_ORIGIN);
|
||||
for (String allowOrigin : corsProperties.getAllowOrigins()) {
|
||||
config.addAllowedOrigin(allowOrigin);
|
||||
}
|
||||
// 允许的头信息
|
||||
config.addAllowedHeader("*");
|
||||
// 允许的请求方式
|
||||
|
@ -0,0 +1,22 @@
|
||||
package io.github.xxyopen.novel.core.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 跨域配置属性
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/17
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "novel.cors")
|
||||
@Data
|
||||
public class CorsProperties {
|
||||
|
||||
/**
|
||||
* 允许跨域的域名
|
||||
* */
|
||||
private List<String> allowOrigins;
|
||||
}
|
@ -27,9 +27,4 @@ public class SystemConfigConsts {
|
||||
* */
|
||||
public static final String NOVEL_ADMIN_KEY = "admin";
|
||||
|
||||
/**
|
||||
* 小说前台门户系统域
|
||||
* */
|
||||
public static final String NOVEL_FRONT_WEB_ORIGIN = "http://localhost:1024";
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import java.util.Objects;
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/17
|
||||
*/
|
||||
@ConditionalOnProperty("jwt.secret")
|
||||
@ConditionalOnProperty("novel.jwt.secret")
|
||||
@Component
|
||||
@Slf4j
|
||||
public class JwtUtils {
|
||||
@ -27,7 +27,7 @@ public class JwtUtils {
|
||||
/**
|
||||
* 注入JWT加密密钥
|
||||
*/
|
||||
@Value("${jwt.secret}")
|
||||
@Value("${novel.jwt.secret}")
|
||||
private String secret;
|
||||
|
||||
/**
|
||||
|
@ -42,6 +42,16 @@ spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: dev
|
||||
# JWT密钥
|
||||
jwt:
|
||||
secret: E66559580A1ADF48CDD928516062F12E
|
||||
|
||||
# 项目配置
|
||||
novel:
|
||||
# 跨域配置
|
||||
cors:
|
||||
# 允许跨域的域名
|
||||
allow-origins:
|
||||
- http://localhost:1024
|
||||
- http://localhost:8080
|
||||
# JWT密钥
|
||||
jwt:
|
||||
secret: E66559580A1ADF48CDD928516062F12E
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user