[Spring Security] Spring Security 사용시 첫 로그인 화면이 뜰 때

KosMos·2023년 2월 2일
0

localhost:3000 (Front)
localhost:8080 (Back)

Access to XMLHttpRequest at 'http://localhost:8080/login'
(redirected from 'http://localhost:3000/userMemberList?page=0')
from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

원인

Spring Security를 사용시
http://localhost:8080/login
페이지에

로그인 화면이 나온다.

해결방법

이 오류를 방지하려면 SpringBoot를 실행 시켜주는 Application에 이걸 추가시켜야 합니다.

  • @SpringBootApplication(exclude = {SecurityAutoConfiguration.class})

이 한줄만 추가하고 SpringBoot Run 실행시

Front 화면

Back 화면


전과 다르게 로그인 화면과 오류는 안 나온다.

0개의 댓글