From 5dfaa68e0ea5346dda5376a7f2ad37533fdfb509 Mon Sep 17 00:00:00 2001 From: Raymond Yang Date: Sat, 8 Aug 2026 19:55:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AA=BF=E6=95=B4CORS=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcrediveclanrecordbackend/plugins/Http.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/club/sakunadaisuki/pcrediveclanrecordbackend/plugins/Http.kt b/src/main/kotlin/club/sakunadaisuki/pcrediveclanrecordbackend/plugins/Http.kt index 20f8dc0..561b5e0 100644 --- a/src/main/kotlin/club/sakunadaisuki/pcrediveclanrecordbackend/plugins/Http.kt +++ b/src/main/kotlin/club/sakunadaisuki/pcrediveclanrecordbackend/plugins/Http.kt @@ -8,13 +8,20 @@ import io.ktor.server.routing.* fun Application.configureHttp() { install(CORS) { + allowHost("localhost:8080") + allowHost("table.sakunadaisuki.club") + allowMethod(HttpMethod.Options) allowMethod(HttpMethod.Put) allowMethod(HttpMethod.Delete) allowMethod(HttpMethod.Patch) allowHeader(HttpHeaders.Authorization) + + allowHeader(HttpHeaders.ContentType) // 處理 JSON 必備 + allowHeader(HttpHeaders.Authorization) // 傳遞 JWT / 身份驗證權限必備 + allowHeader("MyCustomHeader") - anyHost() // @TODO: Don't do this in production if possible. Try to limit it. + //anyHost() // @TODO: Don't do this in production if possible. Try to limit it. } routing { swaggerUI(path = "openapi") {