Hello, I followed the
Kotlin full-stack web app tutorial to make my web app, and I am now working on deploying it to Heroku.
I used MongoDB Atlas to connect Heroku and my database, and the code used is very much the same in the tutorial itself.
I encountered a problem where when I POST through the frontend, I receive a 403 error.
The strange thing is, GET and DELETE requests work just fine, and even when I POST with something like curl, it works perfectly!
The only problem is that POST doesn't work from the frontend.
When this function is called from the frontend:
suspend fun addShoppingListItem(shoppingListItem: ShoppingListItem) {
<http://jsonClient.post|jsonClient.post><Unit>(endpoint + ShoppingListItem.path) {
contentType(ContentType.Application.Json)
body = shoppingListItem
}
}
This is what the server does when it receives a POST request:
post {
collection.insertOne(call.receive<ShoppingListItem>())
call.respond(HttpStatusCode.OK)
}
but
this is what I get every time I perform a POST request through my browser.
Are there any help or docs I might be able to benefit from?