Skip to content

Commit c5d3b0f

Browse files
authored
fix: accept vercel kv env variables (#1315)
1 parent 45ed724 commit c5d3b0f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

platforms/nodejs.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class Redis extends core.Redis {
132132
baseUrl: configOrRequester.url,
133133
retry: configOrRequester.retry,
134134
headers: { authorization: `Bearer ${configOrRequester.token}` },
135-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
135+
136136
agent: configOrRequester.agent,
137137
responseEncoding: configOrRequester.responseEncoding,
138138
cache: configOrRequester.cache ?? "no-store",
@@ -172,19 +172,19 @@ export class Redis extends core.Redis {
172172
*/
173173
static fromEnv(config?: Omit<RedisConfigNodejs, "url" | "token">): Redis {
174174
// @ts-ignore process will be defined in node
175-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
175+
176176
if (process.env === undefined) {
177177
throw new TypeError(
178178
'Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
179179
);
180180
}
181181
// @ts-ignore process will be defined in node
182-
const url = process.env.UPSTASH_REDIS_REST_URL;
182+
const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
183183
if (!url) {
184184
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
185185
}
186186
// @ts-ignore process will be defined in node
187-
const token = process.env.UPSTASH_REDIS_REST_TOKEN;
187+
const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
188188
if (!token) {
189189
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
190190
}

0 commit comments

Comments
 (0)