Mon favicon semble agir tout d'un coup. Je ne suis pas sûr du changement que j'ai fait qui l'a fait échouer, mais ça rendait très bien et maintenant c'est brouillé.Favicon n'est pas correctement rendu, semble brouillé
Voici un échantillon de ce qu'il ressemble à:
J'utilise Spring Boot et googled autour de trouver toutes les réponses typiques sur la façon d'obtenir votre favicon montrant ... mais Je n'ai pas eu de chance. Une chose que j'ai remarquée (je ne sais pas si c'est normal ou non), c'est que quand je visite l'URL de favicon, il ne la charge pas dans le navigateur comme une icône, mais plutôt comme un tas de texte.
Voici ce qui se passe quand je visite mon localhost: url 8080/favicon.ico:
La seule chose que je peux penser que j'ai changé récemment qui aurait eu un effet sur la favicon était mon WebSecurityConfig.java ... J'ai ajouté un REALM et une authentification de base.
Voici le fichier WebSecurityConfig.java:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
{
@Autowired
private UserDetailsService userDetailsService;
private static String REALM="MY_TEST_REALM";
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Autowired
public void globalSecurity (AuthenticationManagerBuilder auth) throws Exception
{
auth.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception
{
// authenticate/authorize
// authentication = who the hell are you? i.e. username/password
// authorization = what can you access in the app?
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/*").permitAll()
.antMatchers("/js/**").permitAll()
.antMatchers("/webinars/**").permitAll()
.antMatchers("/img/**").permitAll()
.antMatchers("/fonts/**").permitAll()
.antMatchers("/register").permitAll()
.antMatchers("/samcart").permitAll()
.antMatchers("/sales").permitAll()
.antMatchers("/sales/**").permitAll()
.antMatchers("/paypal/**").permitAll()
.antMatchers("/forgotPassword").permitAll()
.antMatchers("proffesso-favicon.ico").permitAll()
.antMatchers("/students/purchasedCourse.html").permitAll()
.antMatchers("/students/courses/**").permitAll()
.antMatchers("/teachers/courses/*/image").permitAll()
.antMatchers("/teachers/courses/*/offers/*/image").permitAll()
.antMatchers("/handlebars/**").permitAll()
.antMatchers("/css/**").permitAll()
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/admin").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.httpBasic()
.realmName(REALM)
.authenticationEntryPoint(getBasicAuthEntryPoint())
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/students/courses")
.successHandler(new NoRedirectSavedRequestAwareAuthenticationSuccessHandler())
.permitAll()
.and()
.logout()
.logoutSuccessUrl("/").permitAll()
.and()
.sessionManagement()
.maximumSessions(1);
}
@Bean
public CustomBasicAuthenticationEntryPoint getBasicAuthEntryPoint(){
return new CustomBasicAuthenticationEntryPoint();
}
/* To allow Pre-flight [OPTIONS] request from browser */
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**");
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean()
public SecurityEvaluationContextExtension securityEvaluationContextExtension() {
return new SecurityEvaluationContextExtension();
}
}
Hmmm, apparaît comme quand je le pointer vers un fichier PNG au lieu d'un fichier ICO, il rend correctement. – Trevor
Habituellement, lorsque vous entrez l'URL d'un fichier ICO dans Chrome, il est capable de l'afficher correctement. Ici, vous obtenez simplement les données binaires affichées sous forme de texte. Je vous conseille de regarder le type MIME retourné par votre serveur (il devrait être image/vnd.microsoft.icon). –