CORS configuration for REST api accessed from browser

To allow requests against a Spring Boot REST API from a website it is necessary to configure CORS properly. In case you don’t know your client URLs you can allow all clients by adding a mapping like the following in your Kotlin project:

@Configuration
class RestCorsConfig : WebMvcConfigurer {

    override fun addCorsMappings(@NonNull registry: CorsRegistry) {
        registry.addMapping("/**")
            .allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.DELETE.name())
            .allowedOrigins("*")
    }
}

This allows access to all endpoints from all origins via GET, POST and DELETE methods.