Skip to content

Commit 863d7f0

Browse files
committed
Update README.md: add document for overriding cookies with environment
variables.
1 parent a776ab5 commit 863d7f0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,27 @@ csrf = '<your-leetcode-csrf-token>'
321321
session = '<your-leetcode-session-key>'
322322
```
323323

324+
#### Environment variables
325+
326+
The cookies can also be overridden by environment variables, which might be useful to exclude the sensitive information from the configuration file `leetcode.toml`. To do this, you can leave the `csrf` and `session` fields empty in the configuration file and override cookies settings via the environment variables `LEETCODE_CSRF`, `LEETCODE_SESSION`, and `LEETCODE_SITE`:
327+
328+
```toml
329+
[cookies]
330+
csrf = ''
331+
session = ''
332+
site = 'leetcode.com'
333+
```
334+
335+
Then set the environment variables:
336+
337+
```bash
338+
export LEETCODE_CSRF='<your-leetcode-csrf-token>'
339+
export LEETCODE_SESSION='<your-leetcode-session-key>'
340+
export LEETCODE_SITE='leetcode.cn' # or 'leetcode.com'
341+
```
342+
343+
Note that `cookies.site` in still required in the `leetcode.toml` to avoid exception during configuration file parsing, but can be overridden using environment variables.
344+
324345
## Programmable
325346

326347
If you want to filter LeetCode questions using custom Python scripts, add the following to your the configuration file:

0 commit comments

Comments
 (0)