Skip to content

Commit

Permalink
Reload page when we get a 401 back from bcapp
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwiese committed Oct 4, 2024
1 parent 4bf03ca commit 94a2129
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,20 @@ 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 94a2129

Please sign in to comment.