-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebConfig.java
More file actions
29 lines (24 loc) · 1.07 KB
/
WebConfig.java
File metadata and controls
29 lines (24 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.selab.todo.config;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
// CORS --> 가장 많이 발생
@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
@Bean
public UrlBasedCorsConfigurationSource corsConfigurationSource() {
var corsConfig = new CorsConfiguration();
corsConfig.addAllowedOriginPattern(CorsConfiguration.ALL);
corsConfig.addAllowedHeader(CorsConfiguration.ALL);
corsConfig.addAllowedMethod(CorsConfiguration.ALL);
corsConfig.setAllowCredentials(true);
corsConfig.setMaxAge(3600L);
var corsConfigSource = new UrlBasedCorsConfigurationSource();
corsConfigSource.registerCorsConfiguration("/**", corsConfig);
return corsConfigSource;
}
}