Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add environment variable for API key #831

Merged
merged 16 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/using-jellyseerr/settings/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
12 changes: 11 additions & 1 deletion server/lib/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
Loading