mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: generate secure secret key and prevent default
This commit is contained in:
1 parent
55b61dbcab
commit
f1a50067c5
11 files changed
+45
-5
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import { get } from './utils/env.js'
|
||||
import { get, genSecret } from './utils/env.js'
|
||||
|
||||
const config = {
|
||||
host: get('HOST', 'localhost'),
|
||||
port: get('PORT', 3000),
|
||||
db: get('MONGO_URL', 'mongodb://localhost:27017/odyssey-test'),
|
||||
jwtSecret: get('JWT_SECRET', 'secret'),
|
||||
secret: get('SECRET_KEY', ''),
|
||||
dockerNetwork: get('DOCKER_NETWORK', 'linux-odyssey-players'),
|
||||
isProduction: process.env.NODE_ENV === 'production',
|
||||
hostPwd: get('HOST_PWD', ''),
|
||||
@@ -22,4 +22,11 @@ const config = {
|
||||
|
||||
config.baseUrl = get('BASE_URL', `http://${config.host}:${config.port}`)
|
||||
|
||||
if (!config.secret) {
|
||||
config.secret = genSecret()
|
||||
console.warn(
|
||||
'No SECRET_KEY found in .env! A temporary secret key has been generated. To set up a persistent key, please run the setup script.'
|
||||
)
|
||||
}
|
||||
|
||||
export default config
|
||||
Reference in new issue
Block a user