Skip to content

Commit 1e48cd2

Browse files
feat: cors error fixed
1 parent 54553db commit 1e48cd2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

server/src/main/java/uz/server/config/Beans.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,27 @@
33
import org.springframework.context.annotation.Bean;
44
import org.springframework.context.annotation.Configuration;
55
import org.springframework.web.client.RestTemplate;
6+
import org.springframework.web.servlet.config.annotation.CorsRegistry;
7+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
68

79
@Configuration
810
public class Beans {
911
@Bean
1012
public RestTemplate restTemplate() {
1113
return new RestTemplate();
1214
}
15+
16+
@Bean
17+
public WebMvcConfigurer corsConfigurer() {
18+
return new WebMvcConfigurer() {
19+
@Override
20+
public void addCorsMappings(CorsRegistry registry) {
21+
registry.addMapping("/**")
22+
.allowedOrigins("*")
23+
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
24+
.allowedHeaders("*")
25+
.allowCredentials(true);
26+
}
27+
};
28+
}
1329
}

0 commit comments

Comments
 (0)