kotlin-hands-on / jvm-js-fullstack

https://play.kotlinlang.org/hands-on/Full%20Stack%20Web%20App%20with%20Kotlin%20Multiplatform/
122 stars 148 forks source link

POST request returns 403 error on deployed app #20

Open jpcurbelo opened 2 years ago

jpcurbelo commented 2 years ago

I've followed this tutorial to build a KMM app. Everything works fine when the app is running on the local server but the POST method returns Error 403 when deployed on Heroku. This is the function on the Client side.

val endpoint = window.location.origin // only needed until https://github.com/ktorio/ktor/issues/1695 is resolved

val jsonClient = HttpClient { install(JsonFeature) { serializer = KotlinxSerializer() } }

suspend fun sendfeedback(userinfo: UserInfo) {

jsonClient.post<Unit>(endpoint + UserInfo.path) {

    contentType(ContentType.Application.Json)
    body = userinfo
}

}

racka98 commented 2 years ago

See: https://youtrack.jetbrains.com/issue/KTOR-4008/POST-request-to-database-returns-403-error#focus=Comments-27-6434385.0-0