spring boot security css js img

Crow·2022년 12월 20일
0

http://localhost:8080/login”의 리소스가 MIME 타입(“text/html”)이 일치하지 않아서 (X-Content-Type-Options: nosniff) 차단되었습니다.

해당 문제 해결하려면
Config.java 파일에서

    @Bean
    public WebSecurityCustomizer webSecurityCustomizer() {
        return (web) -> web.ignoring().antMatchers("/static/js/**", "/static/image/**", "/static/css/**", "/static/scss/**").anyRequest();
    }

해당 빈을 구성할때 마지막에 .anyRequest()를 붙여주니까 해결됨


추가내용

해당 빈만 사용시 http://localhost:8080/login 해당 url은 사용을 못함 따라서 이쪽 매핑도 SecurityFilterChain Bean에서 열어줘야함

http.authorizeRequests(authRequest -> authRequest
.antMatchers("원하는 매핑").permitAll().anyRequest().authenticated());
profile
어제보다 개발 더 잘하기 / 많이 듣고 핵심만 정리해서 말하기 / 도망가지 말기 / 깃허브 위키 내용 가져오기

0개의 댓글