david dereba
10/09/2024, 1:03 PMfun Application.configureHTTP() {
install(CORS) {
HttpMethod.DefaultMethods.forEach { allowMethod(it) }
allowHeaders { true }
anyHost() // @TODO: Don't do this in production if possible. Try to limit it.
}
}
fun main(args: Array<String>) {
EngineMain.main(args)
}
fun Application.module() {
configureSerialization()
configureDatabases()
configureHTTP()
configureSecurity()
configureRouting()
DatabaseFactory.init(this)
configureKoin()
testRoutesImplementation()
rolesRoutesImplementation()
usersRoutesImplementation()
userRolesRoutesImplementation()
authenticationImplementation()
locationsRoutesImplementation()
productCategoriesRoutesImplementation()
productsRoutesImplementation()
farmersRoutesImplementation()
aggregatorRoutesImplementation()
aggregatorFarmersRoutesImplementation()
aggregatorProductRoutesImplementation()
storeRoutesImplementation()
summariesRoutesImplementation()
}
Aleksei Tirman [JB]
10/09/2024, 1:11 PMdavid dereba
10/09/2024, 1:14 PMAleksei Tirman [JB]
10/09/2024, 1:16 PMdavid dereba
10/09/2024, 1:22 PMAbdulrahman Al Sabagh (Abudi)
10/09/2024, 1:28 PMdavid dereba
10/09/2024, 1:30 PMAleksei Tirman [JB]
10/09/2024, 1:30 PMAccess-Control-Allow-Origin
header:
curl --request OPTIONS \
--url <http://109.123.254.230:8084/api/auth/v1/login> \
--header 'Access-Control-Request-Method: POST' \
--header 'Origin: <http://localhost:5173>'
Abdulrahman Al Sabagh (Abudi)
10/09/2024, 1:31 PMallowHeader(HttpHeaders.AccessControlAllowOrigin)
You can also try thisAleksei Tirman [JB]
10/09/2024, 1:32 PMdavid dereba
10/09/2024, 1:39 PMRenan Kummer
10/09/2024, 1:59 PMallowNonSimpleContentTypes = true
allowCredentials = true
allowHeader(HttpHeaders.ContentType)
allowHeader(HttpHeaders.Authorization)
This is what I had to allow as a minimum to work with JSON payloads and Authorization header.Aleksei Tirman [JB]
10/09/2024, 1:59 PMAccess-Control-Request-Method
header for some reason.Aleksei Tirman [JB]
10/09/2024, 2:02 PMdavid dereba
10/09/2024, 2:08 PMdavid dereba
10/09/2024, 2:29 PMfun Application.configureHTTP() {
install(CORS) {
HttpMethod.DefaultMethods.forEach { allowMethod(it) }
allowHeaders { true }
allowHeader(HttpHeaders.AccessControlAllowOrigin)
allowCredentials = true
allowNonSimpleContentTypes = true
allowHeader(HttpHeaders.ContentType)
allowHeader(HttpHeaders.Authorization)
anyHost() // @TODO: Don't do this in production if possible. Try to limit it.
}
}
Abdulrahman Al Sabagh (Abudi)
10/09/2024, 2:32 PMallowMethod(HttpMethod.Put)
allowMethod(HttpMethod.Patch)
allowMethod(HttpMethod.Delete)
allowMethod(HttpMethod.Options)
allowMethod(HttpMethod.Get)
allowHeader(HttpHeaders.Authorization)
allowHeader(HttpHeaders.AccessControlAllowOrigin)
allowHeader(HttpHeaders.ContentType)
allowHeader(HttpHeaders.Authorization)
allowCredentials = true
allowSameOrigin = true
anyHost()
Abdulrahman Al Sabagh (Abudi)
10/09/2024, 2:35 PMdavid dereba
10/09/2024, 7:45 PM