/
Sturon
/
Diplom
Обзор
Документация
Войти
/
Sturon
/
Diplom
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/src/main/java/ru/diplom/vision/config/WebConfig.java
37 строк
1 KB
Sturon
Initial
03 июн 2026, 15:01
03 июн 2026, 15:01
17b44a2
Код
Авторство
О чём код?
package ru.diplom.vision.config; import java.nio.file.Path; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class WebConfig implements WebMvcConfigurer { private final String frontendUrl; private final StorageProperties storageProperties; public WebConfig( @Value("${app.frontend-url:http://localhost:5173}") String frontendUrl, StorageProperties storageProperties ) { this.frontendUrl = frontendUrl; this.storageProperties = storageProperties; } @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") .allowedOrigins(frontendUrl) .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS"); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { Path storagePath = Path.of(storageProperties.root()).toAbsolutePath().normalize(); registry.addResourceHandler("/storage/**") .addResourceLocations(storagePath.toUri().toString()); } }