Skip to content

Commit 91830bd

Browse files
committed
Merge branch 'Tattoodo-cookie-safeguard'
2 parents a273116 + 519c93a commit 91830bd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,11 @@ function create(defaults) {
171171
customHeaders['content-type'] = 'application/json';
172172
}
173173

174-
const m =
175-
typeof document !== 'undefined' && document.cookie.match(RegExp('(^|; )' + options.xsrfCookieName + '=([^;]*)'));
176-
if (m) customHeaders[options.xsrfHeaderName] = decodeURIComponent(m[2]);
174+
try {
175+
customHeaders[options.xsrfHeaderName] = decodeURIComponent(
176+
document.cookie.match(RegExp('(^|; )' + options.xsrfCookieName + '=([^;]*)'))[2]
177+
);
178+
} catch (e) {}
177179

178180
if (options.auth) {
179181
customHeaders.authorization = options.auth;

0 commit comments

Comments
 (0)