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:

class RestCorsConfig : WebMvcConfigurer {

    override fun addCorsMappings(@NonNull registry: CorsRegistry) {

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