添加 cors 策略 允许跨域
This commit is contained in:
parent
765b1f6fe8
commit
3ea5ac5deb
@ -5,6 +5,7 @@ import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@ -19,4 +20,14 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
.excludePathPatterns("/swagger-ui/**","/v3/api-docs/**")
|
||||
.addPathPatterns("/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry corsRegistry){
|
||||
corsRegistry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowCredentials(true)
|
||||
.allowedMethods("GET","POST","HEAD","DELETE","PUT")
|
||||
.allowedHeaders("*")
|
||||
.maxAge(3600);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user