1 | //package com.example.rezevirajmasa.demo.config;
|
---|
2 | //
|
---|
3 | //import jakarta.servlet.FilterRegistration;
|
---|
4 | //import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
---|
5 | //import org.springframework.context.annotation.Bean;
|
---|
6 | //import org.springframework.context.annotation.Configuration;
|
---|
7 | //import org.springframework.http.HttpHeaders;
|
---|
8 | //import org.springframework.http.HttpMethod;
|
---|
9 | //import org.springframework.web.cors.CorsConfiguration;
|
---|
10 | //import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
---|
11 | //import org.springframework.web.filter.CorsFilter;
|
---|
12 | //import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
---|
13 | //
|
---|
14 | //import java.util.Arrays;
|
---|
15 | //
|
---|
16 | //@Configuration
|
---|
17 | //@EnableWebMvc
|
---|
18 | //public class WebConfig {
|
---|
19 | // @Bean
|
---|
20 | // public FilterRegistrationBean corsFilter() {
|
---|
21 | // UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
---|
22 | // CorsConfiguration config = new CorsConfiguration();
|
---|
23 | // config.setAllowCredentials(true);
|
---|
24 | // config.addAllowedOrigin("http://localhost:3000");
|
---|
25 | // config.setAllowedHeaders(Arrays.asList(
|
---|
26 | // HttpHeaders.AUTHORIZATION,
|
---|
27 | // HttpHeaders.CONTENT_TYPE,
|
---|
28 | // HttpHeaders.ACCEPT
|
---|
29 | // ));
|
---|
30 | // config.setAllowedMethods(Arrays.asList(
|
---|
31 | // HttpMethod.GET.name(),
|
---|
32 | // HttpMethod.POST.name(),
|
---|
33 | // HttpMethod.PUT.name(),
|
---|
34 | // HttpMethod.DELETE.name()
|
---|
35 | // ));
|
---|
36 | // config.setMaxAge(3600L);
|
---|
37 | // source.registerCorsConfiguration("/**", config);
|
---|
38 | // FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
|
---|
39 | // bean.setOrder(-102);
|
---|
40 | // return bean;
|
---|
41 | // }
|
---|
42 | //}
|
---|