diff --git a/src/main/kotlin/com/ray650128/pcredive/database/model/RecordData.kt b/src/main/kotlin/com/ray650128/pcredive/database/model/RecordData.kt index b1df965..6325e3a 100644 --- a/src/main/kotlin/com/ray650128/pcredive/database/model/RecordData.kt +++ b/src/main/kotlin/com/ray650128/pcredive/database/model/RecordData.kt @@ -5,5 +5,5 @@ import kotlinx.serialization.Serializable @Serializable data class RecordData( val member: Member, - var record: MemberRecord + var record: MemberRecord? ) diff --git a/src/main/kotlin/com/ray650128/pcredive/plugins/HTTP.kt b/src/main/kotlin/com/ray650128/pcredive/plugins/HTTP.kt index 02b27ff..1df3ea2 100644 --- a/src/main/kotlin/com/ray650128/pcredive/plugins/HTTP.kt +++ b/src/main/kotlin/com/ray650128/pcredive/plugins/HTTP.kt @@ -7,11 +7,13 @@ import io.ktor.server.application.* fun Application.configureHTTP() { install(CORS) { allowMethod(HttpMethod.Options) + allowMethod(HttpMethod.Get) allowMethod(HttpMethod.Put) - allowMethod(HttpMethod.Delete) - allowMethod(HttpMethod.Patch) - allowHeader(HttpHeaders.Authorization) + //allowMethod(HttpMethod.Delete) + allowMethod(HttpMethod.Post) allowHeader(HttpHeaders.AccessControlAllowOrigin) + allowHeader(HttpHeaders.Accept) + allowHeader(HttpHeaders.ContentType) anyHost() allowCredentials = true allowNonSimpleContentTypes = true diff --git a/src/main/kotlin/com/ray650128/pcredive/plugins/MemberRecordRouting.kt b/src/main/kotlin/com/ray650128/pcredive/plugins/MemberRecordRouting.kt index 9f40b13..a938496 100644 --- a/src/main/kotlin/com/ray650128/pcredive/plugins/MemberRecordRouting.kt +++ b/src/main/kotlin/com/ray650128/pcredive/plugins/MemberRecordRouting.kt @@ -21,6 +21,9 @@ import java.util.* fun Application.configureMemberRecordRouting() { routing { + options("{...}") { + call.respond(HttpStatusCode.OK) + } route("/api") { route("/record") { get { @@ -134,7 +137,7 @@ fun getData(year: Int, month: Int, day: Int): List { memberList.forEach { member -> if (member.createAt!! < startTime && !member.leave) { records.add( - RecordData(member = member, MemberRecord()) + RecordData(member = member, null) ) } } diff --git a/src/main/kotlin/com/ray650128/pcredive/plugins/MemberRouting.kt b/src/main/kotlin/com/ray650128/pcredive/plugins/MemberRouting.kt index 09367f7..7905a85 100644 --- a/src/main/kotlin/com/ray650128/pcredive/plugins/MemberRouting.kt +++ b/src/main/kotlin/com/ray650128/pcredive/plugins/MemberRouting.kt @@ -16,6 +16,9 @@ import kotlinx.coroutines.coroutineScope fun Application.configureMemberRouting() { routing { + options("{...}") { + call.respond(HttpStatusCode.OK) + } route("/api") { route("/member") { get {