diff --git a/package-lock.json b/package-lock.json index d4e5be8..558300b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bigcommerce/stencil-utils", - "version": "6.15.1", + "version": "6.17.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bigcommerce/stencil-utils", - "version": "6.15.1", + "version": "6.17.0", "license": "BSD-4-Clause", "dependencies": { "eventemitter3": "^4.0.4", @@ -30,7 +30,7 @@ "webpack-cli": "^5.0.1" }, "engines": { - "node": ">=14.0.0 <19.0.0" + "node": ">=18" } }, "node_modules/@ampproject/remapping": { diff --git a/src/lib/request.js b/src/lib/request.js index 8e02f16..713d0ec 100644 --- a/src/lib/request.js +++ b/src/lib/request.js @@ -88,12 +88,19 @@ export default function (relativeUrl, opts, callback) { return fetch(url, config) .then((response) => { - if (response.headers.get('content-type').indexOf('application/json') !== -1) { - return response.json(); + let result = null; + + if (response.status == 401 && response.headers.get('X-BC-Preview-Mode').indexOf('true') !== -1) { + window.location.reload(); + } else { + if (response.headers.get('content-type').indexOf('application/json') !== -1) { + result = response.json(); + } + result = response.text(); } - return response.text(); - }) - .then((response) => { + + return result; + }).then((response) => { const content = options.remote ? response.content : response; let ret = response;