feat(N/A): 配置dev环境的cors配置
This commit is contained in:
@@ -4,12 +4,14 @@ import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.filter.SaServletFilter;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Configuration
|
||||
@Profile("dev")
|
||||
@Slf4j
|
||||
public class SaTokenDevFilterConfig {
|
||||
|
||||
@Bean
|
||||
@@ -18,6 +20,9 @@ public class SaTokenDevFilterConfig {
|
||||
.addInclude("/**")
|
||||
.addExclude("/login")
|
||||
.setBeforeAuth(r -> {
|
||||
String path = SaHolder.getRequest().getRequestPath(); // 不含上下文
|
||||
String method = SaHolder.getRequest().getMethod();
|
||||
log.debug("[DEV] {} {}", method, path);
|
||||
if ("OPTIONS".equalsIgnoreCase(SaHolder.getRequest().getMethod())) {
|
||||
SaHolder.getResponse().setStatus(200);
|
||||
SaRouter.back();
|
||||
|
||||
Reference in New Issue
Block a user