diff --git a/src/index.js b/src/index.js index 3f565b8..cd1dda6 100644 --- a/src/index.js +++ b/src/index.js @@ -173,8 +173,13 @@ export default (function create(/** @type {Options} */ defaults) { customHeaders['content-type'] = 'application/json'; } - const m = - typeof document !== 'undefined' && document.cookie.match(RegExp('(^|; )' + options.xsrfCookieName + '=([^;]*)')); + let m; + + try { + m = + typeof document !== 'undefined' && + document.cookie.match(RegExp('(^|; )' + options.xsrfCookieName + '=([^;]*)')); + } catch (e) {} if (m) customHeaders[options.xsrfHeaderName] = decodeURIComponent(m[2]); if (options.auth) {