Added CORS headers to response

This commit is contained in:
dankito 2021-01-02 22:47:28 +01:00
parent bc6e8aed51
commit f7fe09ecd9
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package net.dankito.banking.fints.rest
import javax.annotation.Priority
import javax.ws.rs.Priorities
import javax.ws.rs.container.ContainerRequestContext
import javax.ws.rs.container.ContainerResponseContext
import javax.ws.rs.container.ContainerResponseFilter
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.ext.Provider
@Provider
@Priority(Priorities.HEADER_DECORATOR)
open class AccessControlResponseFilter : ContainerResponseFilter {
override fun filter(requestContext: ContainerRequestContext, responseContext: ContainerResponseContext) {
val headers: MultivaluedMap<String, Any> = responseContext.headers
headers.add("Access-Control-Allow-Origin", "*")
headers.add("Access-Control-Allow-Headers", "Authorization, Origin, X-Requested-With, Content-Type")
headers.add("Access-Control-Expose-Headers", "Location, Content-Disposition")
headers.add("Access-Control-Allow-Methods", "POST, PUT, GET, DELETE, HEAD, OPTIONS")
}
}