Skip to content

Commit 4f822ff

Browse files
fix(auth): add prefix for basic auth header
Add 'Basic ' as prefix for the Authorization header when using basic authentication
1 parent abfc292 commit 4f822ff

File tree

1 file changed

+3
-2
lines changed
  • playgrounds/firecamp-rest/src/services/auth/helpers

1 file changed

+3
-2
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { IAuthBasic } from '@firecamp/types';
22

33
export default ({ username, password }: IAuthBasic): string => {
4+
const _p = 'Basic';
45
const _s = `${username}:${password}`;
56
if (typeof window !== 'undefined') {
67
// Browser
78
const utf8String = unescape(encodeURIComponent(_s));
89
const base64String = btoa(utf8String);
9-
return base64String;
10+
return `${_p} ${base64String}`;
1011
} else {
1112
// Node.js
1213
const utf8String = Buffer.from(_s, 'utf8');
1314
const base64String = utf8String.toString('base64');
14-
return base64String;
15+
return `${_p} ${base64String}`;
1516
}
1617
};

0 commit comments

Comments
 (0)