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 0abaf1d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 0abaf1d

Please sign in to comment.