How to read array environment variable in application.conf?

Viewed 3706

I would like to define in application.conf a variable which will be a list of strings. Currently in application.conf I have something like this:

some.env.variable = ["a", "b"]

I tried:

some.env.variable = ${?I_AM_ENV}.split(",")

when I_AM_ENV = a,b but it didn't work.

I get an error when loading app:

Wrong value type at 'some.env.variable', expecting: list but got: string
2 Answers

Took a while but we found it.

application.conf

    access-control-allow-origin = ["http://localhost:4444"]
    access-control-allow-origin = ${?CLIENT_DOMAIN}
    export CLIENT_DOMAIN.0=http://localhost:3000
    export CLIENT_DOMAIN.1=http://localhost:3001

According to documentation:

// in your env
export OPTIONAL_A='"b", "c"'

// in application.conf
path = [ "a", ${?OPTIONAL_A} ]

should evaluate path to ["a", "b", "c"]

Related