Attempt to allow sub paths (routing) 2

This commit is contained in:
bskjon 2025-02-23 03:47:37 +01:00
parent 136ac4e0a7
commit da0470e88f
2 changed files with 6 additions and 5 deletions

View File

@ -22,7 +22,7 @@ class WebConfig: WebMvcConfigurer {
override fun addCorsMappings(registry: CorsRegistry) { override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**") registry.addMapping("/**")
.allowedOrigins("localhost", "*://localhost:3000", "localhost:80") .allowedOrigins("localhost", "*://localhost:3000", "localhost:80")
.allowCredentials(false) .allowCredentials(true)
} }
override fun addResourceHandlers(registry: ResourceHandlerRegistry) { override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
@ -32,13 +32,14 @@ class WebConfig: WebMvcConfigurer {
} }
override fun addViewControllers(registry: ViewControllerRegistry) { override fun addViewControllers(registry: ViewControllerRegistry) {
// Sørger for at alle ikke-API-ruter sendes til React sin index.html // Endrer på denne linjen for å være mer presis
registry.addViewController("/{spring:[^api].*}") registry.addViewController("/")
.setViewName("forward:/index.html") .setViewName("forward:/index.html")
// Denne fanger andre ruter som ikke starter med `/api`
registry.addViewController("/**/{spring:[^api].*}") registry.addViewController("/**/{spring:[^api].*}")
.setViewName("forward:/index.html") .setViewName("forward:/index.html")
} }
override fun configurePathMatch(configurer: PathMatchConfigurer) { override fun configurePathMatch(configurer: PathMatchConfigurer) {
configurer.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController::class.java)) configurer.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController::class.java))
} }

View File

@ -12,7 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling
import org.springframework.scheduling.annotation.Scheduled import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
@Service //@Service
@EnableScheduling @EnableScheduling
class EventExecutionOrderService( class EventExecutionOrderService(
@Autowired eventsManager: EventsManager @Autowired eventsManager: EventsManager