mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
17.56.2021 812f12a69468d5b20fef7afc6cd82c130481e9ad
borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/WebConfig.kt
@@ -1,10 +1,13 @@
package de.micromata.borgbutler.server
import mu.KotlinLogging
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.ViewResolver
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.EnableWebMvc
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
import org.springframework.web.servlet.view.InternalResourceViewResolver
private val log = KotlinLogging.logger {}
@@ -12,6 +15,18 @@
@Configuration
@EnableWebMvc
open class WebConfig : WebMvcConfigurer {
    @Bean
    open fun internalResourceViewResolver(): ViewResolver {
        val bean = InternalResourceViewResolver()
        if (RunningMode.webBundled()) {
            bean.setPrefix("/web/")
        } else {
            bean.setPrefix("borgbutler-webapp/build/")
        }
        bean.setSuffix(".html")
        return bean
    }
    override fun addCorsMappings(registry: CorsRegistry) {
        if (RunningMode.webDevelopment) {
            log.warn("*********************************")