mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:57:08 +00:00
Autogenerate JWT secret if not in production mode
This commit is contained in:
@@ -40,6 +40,16 @@ try {
|
||||
if (text) {
|
||||
config = JSON.parse(text);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV != "production") {
|
||||
if (!config.jwt || !config.jwt.secret) {
|
||||
const buffer = Buffer.alloc(64);
|
||||
crypto.randomFillSync(buffer, 0, buffer.length);
|
||||
config.jwt.secret = buffer.toString("base64");
|
||||
console.warn("Autogenerated JWT secret (NODE_ENV != production)");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
Reference in New Issue
Block a user