diff --git a/docs/using-jellyseerr/settings/general.md b/docs/using-jellyseerr/settings/general.md index 9cec9b9f3..61991ed0a 100644 --- a/docs/using-jellyseerr/settings/general.md +++ b/docs/using-jellyseerr/settings/general.md @@ -12,6 +12,8 @@ This is your Jellyseerr API key, which can be used to integrate Jellyseerr with If you need to generate a new API key for any reason, simply click the button to the right of the text box. +If you want to set the API key, rather than letting it be randomly generated, you can use the API_KEY environment variable. Whatever that variable is set to will be your API key. + ## Application Title If you aren't a huge fan of the name "Jellyseerr" and would like to display something different to your users, you can customize the application title! diff --git a/server/lib/settings/index.ts b/server/lib/settings/index.ts index 8c55d6c3d..074a4fcdc 100644 --- a/server/lib/settings/index.ts +++ b/server/lib/settings/index.ts @@ -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;