@gameforyouonline

Почему доступ к статическим файлам 401, а к другим есть?

Добр. день возникла ошибка при использовании token на фронте. На фронте получаю обьект, но при отображении картинки, получаю ошибку доступа 401...все другие данние показивает. Для backenda использую spring, фронт - React
<img src={props.photoUrl} alt={props.title} className='mySwiperImg' loading='lazy' />

Spring:
@RequiredArgsConstructor
@Configuration
@EnableWebSecurity
public class SecurityConfig {

    private final UserAuthenticationEntryPoint userAuthenticationEntryPoint;
    private final UserAuthProvider userProvider;
    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        return http
                .exceptionHandling().authenticationEntryPoint(userAuthenticationEntryPoint)
                .and()
                .addFilterBefore(new JwtAuthFilter(userProvider), BasicAuthenticationFilter.class)
                .csrf().disable()
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and()
                .authorizeRequests(authorizeRequests ->
                        authorizeRequests
                                .antMatchers(HttpMethod.POST, "/login", "/register").permitAll()
                                .anyRequest().authenticated()
                )
                .build();
    }
}

public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(new String[]{"/app/uploads/**", "/uploads/**"}).addResourceLocations(new String[]{"file:/app/uploads/", "file:./uploads/"});
    }


64e4d84c56fc2194220060.png
64e4d859da509736683134.png

В чем может бить проблема?
  • Вопрос задан
  • 29 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы