Hi, I have a question regarding the `application.c...
# server
a
Hi, I have a question regarding the
application.conf
file when using
ktor.
I’m trying this for the first time so pardon me. I’ve created a conf file as follows:
Copy code
ktor {
  deployment {
      port = 8080
  }

  application {
      modules = [ com.example.ApplicationKt.module ]
  }
}

jwt {
 "secret" = ${m_secret}
 "issuer" = "my_issuer"
 ….
}
I would like to extract the values for the
jwt
properties into an environment file so that i don’t publish my secrets into version control. What’s the best way to do this? I tried accessing the value of
${m_secret}
from a
dev.env
file which I set as
m_secret="secret"
but that didn’t work as I run into the following error:
Could not resolve substitution to a value: ${m_secret}
. Thanks in advance.
d
The syntax looks correct, are you sure that the
dev.env
file is correctly used for variable substitution? Have you tried running with a direct environment variable?
g
m_secret
is the value. I guess, you should use the key:
secret
, probably with its path:
jwt.secret
.
a
I think the
.conf
file is just a text file, so I don’t think it’ll grab the actual environment variable. Those variables are used in
Security.kt
in the default project setup, so you could access the environment variables there instead.
a
Thanks for all the help. So I finally figured it out. I’m using IntelliJ and in the
Run/Debug Configurations
I had to enable the use of the
EnvFile
and attach my
dev.env
file as shown in the attached image. After that, I could pass the environment variables from my
dev.env
file.
👍 1