Configuration error [application secret not set]

I got this error when starting the Play 2.4 server in production mode:

play.api.UnexpectedException: Unexpected exception[ProvisionException: Unable to provision, see the following errors:

1) Error in custom provider, @6mh5cjo5l: Configuration error
  while locating play.api.libs.CryptoConfigParser
  while locating play.api.libs.CryptoConfig

...

Caused by: play.api.PlayException: Configuration error[Application secret not set]

      

How to fix?

+3


source to share


1 answer


The default template uses the following:

play.crypto.secret="changeme"

      

c application.conf

, which needs to be modified for production use. Play provides a utility to generate a random mystery for you:

./activator playGenerateSecret

      

with which you can fill in as an environment variable:

APPLICATION_SECRET=...

      



and to conf/application.conf

provide the following:

play.crypto.secret="changeme"
play.crypto.secret=${?APPLICATION_SECRET}

      

which, like the Reproduction Documentation explains:

The second line in this configuration sets the secret coming from an environment variable called APPLICATION_SECRET if such an environment variable is set, otherwise it leaves the secret unchanged from the previous line.

Then the error will disappear.

+8


source







All Articles