Reputation: 1
I have Spring Boot(2.5.4) Vaadin(21) project in production. In this project i use custom images and icons in /resources/META-INF/resources/icons(images). I added push notifications in my project with using nl.martijndwars dependency. In guide i needed to move my sw.ts(Service Worker file, generated by vaadin) to frontend folder. Since i've done it, some of my custom icons do not always load. (405 code. GET method no allowed) mistake code
When i start app on localhost and open it in Google Chrome, only some images didn't load. Cause they were cached. So, if i open app in, for example, Microsoft Edge, all icons/images are gone with the same mistake.
WHAT I'VE TRIED:
I thought the problem is in spring security config. So i've tried different ways to allow icons folder in spring config
spring security config
spring security config 2
Maybe the main problem is with caching images by this script(sw.ts)? sw.ts Please, help! I want my icons/images back!)
Upvotes: 0
Views: 167
Reputation: 10643
It depends what version of Spring Boot you are using. With Spring Boot 3.1 or newer the configuration in VaadinWebSecurity goes like this (code below is not full, but shows the relevant part).
@Configuration
public class SecurityConfig extends VaadinWebSecurity {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(
authorize -> authorize.requestMatchers(new AntPathRequestMatcher("/images/*.png"),
new AntPathRequestMatcher("/icons/*.png"), new AntPathRequestMatcher("/icons/*.svg"))
.permitAll());
super.configure(http);
setLoginView(http, LoginView.class);
}
}
Upvotes: 0