Refactor WebConfig and SecurityConfig to enhance routing with /api prefix, disable CSRF and anonymous access; update OpenAPI paths accordingly. Add HomeController for default route handling.

This commit is contained in:
2025-07-31 21:32:55 +02:00
parent 3f76a98409
commit 8a839ac922
3 changed files with 44 additions and 29 deletions
@@ -3,6 +3,8 @@ package com.alttd.altitudeweb.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.PathResourceResolver;
@@ -15,7 +17,7 @@ public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/")
.addResourceLocations("classpath:/static/browser")
.resourceChain(true)
.addResolver(new PathResourceResolver() {
@Override
@@ -26,8 +28,17 @@ public class WebConfig implements WebMvcConfigurer {
return requestedResource;
}
return new ClassPathResource("/static/index.html");
return new ClassPathResource("/static/browser/index.html");
}
});
}
@Controller
public static class HomeController {
@GetMapping("/")
public String index() {
return "forward:/index.html";
}
}
}