Server: CORS support on SSE routes
This commit is contained in:
@@ -37,9 +37,6 @@ fun Application.module() {
|
|||||||
json()
|
json()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
install(SSE) {}
|
|
||||||
|
|
||||||
val allowLocalhost = environment.config.propertyOrNull("ktor.cors.enableLocalhostOn")?.getString() ?: "0"
|
val allowLocalhost = environment.config.propertyOrNull("ktor.cors.enableLocalhostOn")?.getString() ?: "0"
|
||||||
val safeOrigin = environment.config.propertyOrNull("ktor.cors.browserOrigin")?.getString()
|
val safeOrigin = environment.config.propertyOrNull("ktor.cors.browserOrigin")?.getString()
|
||||||
install(CORS) {
|
install(CORS) {
|
||||||
@@ -73,6 +70,8 @@ fun Application.module() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install(SSE) {}
|
||||||
|
|
||||||
install(StatusPages) {
|
install(StatusPages) {
|
||||||
status(HttpStatusCode.Forbidden) { call, status ->
|
status(HttpStatusCode.Forbidden) { call, status ->
|
||||||
call.respond(status, ErrorResponse("Access Forbidden: CORS failed."))
|
call.respond(status, ErrorResponse("Access Forbidden: CORS failed."))
|
||||||
|
|||||||
Reference in New Issue
Block a user