Skip to content

Commit

Permalink
Merge pull request #216 from bigcommerce/STRF-12520
Browse files Browse the repository at this point in the history
Reload page when we get a 401 back from bcapp
  • Loading branch information
jmwiese authored Oct 7, 2024
2 parents 4bf03ca + 82fef93 commit a908f68
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ 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();
} else {
result = response.text();
}
return response.text();
})
.then((response) => {

return result;
}).then((response) => {
const content = options.remote ? response.content : response;
let ret = response;

Expand Down

0 comments on commit a908f68

Please sign in to comment.