Skip to content

Commit 866ff27

Browse files
committed
only add authorization when token exists
1 parent 5de1226 commit 866ff27

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/server/service/fetcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { Logger, mongoId, sleep } from '../utils';
77
const logger = new Logger('fetcher');
88
const fetch = (url: string, type: 'get' | 'post' = 'get') => {
99
const endpoint = new URL(url, config.server).toString();
10-
const req = superagent[type](endpoint)
11-
.set('Authorization', config.token)
10+
let req = superagent[type](endpoint)
1211
.set('Accept', 'application/json')
1312
.ok(() => true);
13+
if (config.token) req = req.set('Authorization', config.token);
1414
return new Proxy(req, {
1515
get(target, prop) {
1616
if (prop === 'then') {

0 commit comments

Comments
 (0)