Quantcast
Channel: CSSタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9004

Spring Security loginページにcss適用できない(MIME type ('text/html') is not a supported...)

$
0
0

Spring Securityを使用してloginページでcssを適用とした際に以下エラーが発生

console
Refused to apply style from 'http://localhost:8080/login' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
login.html
<!DOCTYPE html><htmllang="ja"xmlns:th="http://www.thymeleaf.org"><head><metacharset="UTF-8"><linkth:href="@{/css/public/login.css}"rel="stylesheet"/>

type="text/css"は不要だが念のため指定したりしても変化なし。
パスのエラーでもない。と少し悩んでいたところ・・・・

結論

Spring Securityでアクセス制限の対象になっていた。
セキュリティ対象外に追加してあげるとうまくいく。

SecurityConfig.kt
@Configuration@EnableWebSecurityclassSecurityConfig:WebSecurityConfigurerAdapter(){overridefunconfigure(web:WebSecurity){// セキュリティ設定無視の設定web.ignoring().antMatchers("/images/**","/css/**"// ←これを追加して解決)}

Viewing all articles
Browse latest Browse all 9004

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>