Skip to content

Commit

Permalink
Merge pull request #28 from jacob-carlborg-apoex/accept-header-23
Browse files Browse the repository at this point in the history
Fix #23: Incorrect Accept header used
  • Loading branch information
jorgemanrubia authored Dec 19, 2024
2 parents a972448 + 3c0a797 commit 1423b29
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/assets/javascripts/hotwire_spark.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,11 @@ var HotwireSpark = (function () {
let currentUrl = cacheBustedUrl(urlWithParams(window.location.href, {
hotwire_spark: "true"
}));
const response = await fetch(currentUrl);
const response = await fetch(currentUrl, {
headers: {
"Accept": "text/html"
}
});
if (!response.ok) {
throw new Error(`${response.status} when fetching ${currentUrl}`);
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/hotwire_spark.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/javascripts/hotwire_spark.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/javascript/hotwire/spark/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function cacheBustedUrl(urlString) {

export async function reloadHtmlDocument() {
let currentUrl = cacheBustedUrl(urlWithParams(window.location.href, { hotwire_spark: "true" }))
const response = await fetch(currentUrl)
const response = await fetch(currentUrl, { headers: { "Accept": "text/html" }})

if (!response.ok) {
throw new Error(`${response.status} when fetching ${currentUrl}`)
Expand Down

0 comments on commit 1423b29

Please sign in to comment.