I have an already advanced project with spring boot with thymeleaf and recently I went to add a new template with awesome font, among others.
The problem is:
Only for some types of files I always get a 404 error (Example .map, .woff, .ttf, among others). error img
As they were able to check the .map of the 404, but the .css loaded correctly, this already discards the issue of incorrect path.
I really need your help! Thank you!
Segue algumas das configurações importantes:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig {
@Autowired
private CustomAuthenticationProvider authenticationProvider;
@Bean
protected SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((requests) -> requests
.requestMatchers("/", "/public/**", "/login/**", "/logout").permitAll()
.anyRequest().authenticated())
.formLogin(formLogin -> formLogin
.loginPage("/login/signIn")
.permitAll()
.failureUrl("/login/signIn?error=true"))
.csrf(AbstractHttpConfigurer::disable).httpBasic();
http.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
.maximumSessions(1)
.expiredUrl("/login/notAuthorized")
.and()
.sessionFixation()
.migrateSession();
http.logout()
.logoutUrl("/login/SignOut")
.logoutSuccessUrl("/")
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID");
return http.build();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception {
return authenticationConfiguration.getAuthenticationManager();
}
@Bean
public AuthenticationManager authManager(HttpSecurity http) throws Exception {
AuthenticationManagerBuilder authenticationManagerBuilder =
http.getSharedObject(AuthenticationManagerBuilder.class);
authenticationManagerBuilder.authenticationProvider(authenticationProvider);
return authenticationManagerBuilder.build();
}
}
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/public/**")
.addResourceLocations("classpath:/static/")
.setCachePeriod(3600)
.resourceChain(true);
}
}