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 2, 2024
1 parent 4bf03ca commit 28084bd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 28084bd

Please sign in to comment.