Skip to content

Commit

Permalink
fix: don't conceal form post response errors
Browse files Browse the repository at this point in the history
  • Loading branch information
roydejong committed Jan 25, 2024
1 parent c659adf commit 8aa93a6
Show file tree
Hide file tree
Showing 3 changed files with 1,153 additions and 1,169 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stim.js",
"version": "0.13.2",
"version": "0.13.3",
"description": "Lightweight drop-in frontend framework for SSR apps",
"main": "build/stim.js",
"license": "MIT",
Expand Down
13 changes: 10 additions & 3 deletions src/core/Applicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ export default class Applicator {
static handleXhrResult(href, xhr, writeHistory = false, isFormPost = false) {
if (xhr.status >= 400) {
// 4XX or 5XX server error, XHR load failed
// redirect the browser for real to handle the situation (e.g. show error page)
Stim.log(`Hard redirecting user, got bad response code (${xhr.status})`);
document.location = href;
if (isFormPost) {
// as this error result is from a form post, we can't redirect the browser
// instead, show the raw error page
Stim.log(`XHR failed for form post, showing error page`);
document.body.innerHTML = xhr.response;
} else {
// redirect the browser for real to handle the situation (e.g. show error page)
Stim.log(`Hard redirecting user, got bad response code (${xhr.status})`);
document.location = href;
}
return;
}

Expand Down
Loading

0 comments on commit 8aa93a6

Please sign in to comment.