
cors 오류 발생.
//Cors 설정
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOriginPatterns(Collections.singletonList("*"));
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
configuration.setAllowedHeaders(List.of("authorization", "content-type", "x-auth-token"));
configuration.setExposedHeaders(Collections.singletonList("x-auth-token"));
configuration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}

말끔.
로그인 테스트
function main()
{
var data = {
"userEmail" : "[email protected]",
"userPassword" : "abcdefg"
};
$.ajax
({
url: "<http://localhost:8080/userlogin>",
data : JSON.stringify(data),
type : "POST",
contentType: "application/json; charset=utf-8",
success: function(data)
{
console.log(data);
}
});
}
