Hello. I am creating a sample app that serves both...
# ktor
a
Hello. I am creating a sample app that serves both frontend and backend on different ports. I am looking at this code: https://github.com/ktorio/ktor-documentation/blob/2.2.3/codeSnippets/snippets/cors/src/main/kotlin/com/example/Application.ktThis and it uses embedded server. I want to use application.conf. Can anyone help me achieve it?
a
You can read about it in the documentation.
a
It doesn't have multiple port specification. It seems if i use application.conf, my server is only listening to one port.
Hello @Aleksei Tirman [JB]. it's been a while but let me ask the same question in a different way. Is there any way to listen to two ports when i start the server using application.conf? I just wanted to do the following // in Application.kt fun main(args: Array<String>) { val env = applicationEngineEnvironment { module { backend() frontend() } connector { host = "0.0.0.0" port = 8080 } connector { host = "0.0.0.0" port = 3000 } } embeddedServer(Netty, env).start(true) } using application.conf. So, something I expected working was: // Application.kt: fun main(args: Array<String>) : Unit = EngineMain.main(args) // application.conf: ktor { deployment { port = 8080 host = "0.0.0.0" } deployment { port = 3000 host = "0.0.0.0" } application { modules = [ com.sample.ApplicationKt.backend, com.sample.ApplicationKt.frontend ] } } Thanks.
a
Unfortunately, that’s not possible.
đź‘Ť 1