From 62f952ac68d6176dba1cf97fbfc32459eb52ad53 Mon Sep 17 00:00:00 2001 From: jay-tux Date: Thu, 27 Aug 2026 14:29:27 +0200 Subject: [PATCH] CORS headers for SSE --- server/src/main/kotlin/com/jaytux/phoebench/server/Main.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/main/kotlin/com/jaytux/phoebench/server/Main.kt b/server/src/main/kotlin/com/jaytux/phoebench/server/Main.kt index 352f585..44ed0df 100644 --- a/server/src/main/kotlin/com/jaytux/phoebench/server/Main.kt +++ b/server/src/main/kotlin/com/jaytux/phoebench/server/Main.kt @@ -40,14 +40,20 @@ fun Application.module() { val allowLocalhost = environment.config.propertyOrNull("ktor.cors.enableLocalhostOn")?.getString() ?: "0" val safeOrigin = environment.config.propertyOrNull("ktor.cors.browserOrigin")?.getString() install(CORS) { + // -- methods -- allowMethod(HttpMethod.Options) allowMethod(HttpMethod.Delete) allowMethod(HttpMethod.Patch) allowMethod(HttpMethod.Get) allowMethod(HttpMethod.Post) + // -- headers -- allowHeader(HttpHeaders.Accept) + allowHeader(HttpHeaders.Pragma) allowHeader(HttpHeaders.Authorization) allowHeader(HttpHeaders.ContentType) + allowHeader(HttpHeaders.CacheControl) + allowHeader(HttpHeaders.LastEventID) + // -- exposed headers -- exposeHeader(HttpHeaders.ContentType) allowCredentials = true allowNonSimpleContentTypes = true