mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-08 02:04:04 +08:00
33 lines
1.1 KiB
Java
33 lines
1.1 KiB
Java
package xyz.playedu.api.config;
|
|
|
|
import jakarta.annotation.Resource;
|
|
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;
|
|
import xyz.playedu.api.middleware.AdminAuthMiddleware;
|
|
|
|
@Configuration
|
|
@Slf4j
|
|
public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
|
@Resource
|
|
private AdminAuthMiddleware adminAuthMiddleware;
|
|
|
|
@Override
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
registry.addInterceptor(adminAuthMiddleware).addPathPatterns("/backend/**");
|
|
}
|
|
|
|
@Override
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
registry.addMapping("/**")
|
|
.allowCredentials(false)
|
|
.allowedOrigins("*")
|
|
.allowedHeaders("*")
|
|
.allowedMethods("GET", "PUT", "POST", "DELETE")
|
|
.exposedHeaders("*");
|
|
}
|
|
}
|