mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-10 08:38:17 -05:00
feat: add environment variable for API key (#831)
* Added the ability to set the API key with the env var API_KEY * Adding debug statements * Updating * feat: adding env var for API key * feat: update * fix(settings/index.ts): remove a print statement that logs the API key to the console * Update en.json * docs: added documentation about API_KEY environment variable * feat: add a check to ensure API key always uses env var if provided * feat: always check the API_KEY env var at startup * chore: add back the gitkeeps under ./config, accidentally deleted in prev commit * chore: revert change made to docker-compose that was accidentally committed
This commit is contained in:
@@ -611,7 +611,11 @@ class Settings {
|
||||
}
|
||||
|
||||
private generateApiKey(): string {
|
||||
return Buffer.from(`${Date.now()}${randomUUID()}`).toString('base64');
|
||||
if (process.env.API_KEY) {
|
||||
return process.env.API_KEY;
|
||||
} else {
|
||||
return Buffer.from(`${Date.now()}${randomUUID()}`).toString('base64');
|
||||
}
|
||||
}
|
||||
|
||||
private generateVapidKeys(force = false): void {
|
||||
@@ -648,6 +652,12 @@ class Settings {
|
||||
|
||||
this.data = merge(this.data, parsedJson);
|
||||
|
||||
if (process.env.API_KEY) {
|
||||
if (this.main.apiKey != process.env.API_KEY) {
|
||||
this.main.apiKey = process.env.API_KEY;
|
||||
}
|
||||
}
|
||||
|
||||
this.save();
|
||||
}
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user