diff --git a/Gemfile.lock b/Gemfile.lock index 327229d..0b92123 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,6 +37,8 @@ GEM nokogiri (>= 1.5.9) method_source (1.0.0) minitest (5.14.4) + nokogiri (1.12.3-arm64-darwin) + racc (~> 1.4) nokogiri (1.12.3-x86_64-darwin) racc (~> 1.4) nokogiri (1.12.3-x86_64-linux) @@ -63,6 +65,7 @@ GEM zeitwerk (2.4.2) PLATFORMS + arm64-darwin-21 x86_64-darwin-18 x86_64-linux diff --git a/app/assets/javascripts/requestjs.js b/app/assets/javascripts/requestjs.js index c72e4be..e1957fc 100644 --- a/app/assets/javascripts/requestjs.js +++ b/app/assets/javascripts/requestjs.js @@ -133,7 +133,8 @@ class FetchRequest { if (response.unauthenticated && response.authenticationURL) { return Promise.reject(window.location.href = response.authenticationURL); } - if (response.ok && response.isTurboStream) { + const responseStatusIsTurboStreamable = response.ok || response.unprocessableEntity; + if (responseStatusIsTurboStreamable && response.isTurboStream) { await response.renderTurboStream(); } return response; @@ -159,7 +160,7 @@ class FetchRequest { headers: this.headers, body: this.formattedBody, signal: this.signal, - credentials: "same-origin", + credentials: this.credentials, redirect: this.redirect }; } @@ -232,6 +233,9 @@ class FetchRequest { get redirect() { return this.options.redirect || "follow"; } + get credentials() { + return this.options.credentials || "same-origin"; + } get additionalHeaders() { return this.options.headers || {}; }