セキュリティ設定による共通Webフォントの許可 パーマリンク to "セキュリティ設定による共通Webフォントの許可"

このTipは@dinu0000により提出されました

JHipster Webアプリケーションを開発する場合、セキュリティ構成のためにWebフォントが正しくロードされないという問題が発生することがあります。一般的なWebフォントをシームレスにロードできるようにするには、次の手順に従います。

SecurityConfiguration.javaファイルのfilterChainメソッドを更新して、Webフォントの要求を許可します。

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
    // ...
    http
        // other configurations
        .authorizeHttpRequests(authz ->
            authz
                .requestMatchers("/", "/index.html", "/*.js", "/*.map", "/*.css").permitAll()
                .requestMatchers("/*.ico", "/*.png", "/*.svg", "/*.webapp").permitAll()
                .requestMatchers("/*.ico", "/*.png", "/*.svg", "/*.webapp", "/*.woff", "/*.woff2", "/*.ttf", "/*.otf").permitAll() // add common web font extensions here 
                .requestMatchers("/app/**").permitAll()
                // ... other configurations
}

これらの設定により、あなたのJHipsterアプリのセキュリティ設定は、セキュリティ制限に遭遇することなく、通常のウェブフォントのロードを可能にします。