From 9be721dcf493f83c5410f04e8dadc033a2bc8fc8 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Fri, 11 Nov 2022 23:46:21 -0600 Subject: [PATCH] send xhr header so errors don't give back HTML pages --- files/assets/js/emoji_modal.js | 1 + files/assets/js/submit.js | 1 + files/templates/casino/game_screen.html | 1 + files/templates/casino/roulette_screen.html | 2 ++ files/templates/casino/slots_screen.html | 1 + files/templates/home.html | 1 + 6 files changed, 7 insertions(+) diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index cf438fee1..aaeef18db 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -188,6 +188,7 @@ const emojisSearchDictionary = { // get public emojis list const emojiRequest = new XMLHttpRequest(); emojiRequest.open("GET", '/marsey_list.json'); +emojiRequest.setRequestHeader('xhr', 'xhr'); emojiRequest.onload = async (e) => { console.log("HERE") let emojis = JSON.parse(emojiRequest.response); diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index 66a43ca01..8dd91e444 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -147,6 +147,7 @@ function autoSuggestTitle() { } } x.open('get','/submit/title?url=' + urlField.value); + x.setRequestHeader('xhr', 'xhr'); x.send(null); }; diff --git a/files/templates/casino/game_screen.html b/files/templates/casino/game_screen.html index 838cb4e50..3b41b1b80 100644 --- a/files/templates/casino/game_screen.html +++ b/files/templates/casino/game_screen.html @@ -131,6 +131,7 @@ const game = document.getElementById('casino-game-wrapper').dataset.game; const xhr = new XMLHttpRequest(); xhr.open("get", `/casino/${game}/feed`); + xhr.setRequestHeader('xhr', 'xhr'); xhr.onload = handleFeedResponse.bind(null, xhr); xhr.send(); } diff --git a/files/templates/casino/roulette_screen.html b/files/templates/casino/roulette_screen.html index 80a6933d2..56e303862 100644 --- a/files/templates/casino/roulette_screen.html +++ b/files/templates/casino/roulette_screen.html @@ -324,6 +324,7 @@ if (confirmed) { const xhr = new XMLHttpRequest(); xhr.open("post", "/casino/roulette/place-bet"); + xhr.setRequestHeader('xhr', 'xhr'); xhr.onload = handleRouletteResponse.bind(null, xhr); const form = new FormData(); @@ -354,6 +355,7 @@ function requestRouletteBets() { const xhr = new XMLHttpRequest(); xhr.open("get", "/casino/roulette/bets"); + xhr.setRequestHeader('xhr', 'xhr'); xhr.onload = handleRouletteResponse.bind(null, xhr); xhr.send(); } diff --git a/files/templates/casino/slots_screen.html b/files/templates/casino/slots_screen.html index dfc1c6261..604e6b041 100644 --- a/files/templates/casino/slots_screen.html +++ b/files/templates/casino/slots_screen.html @@ -13,6 +13,7 @@ const xhr = new XMLHttpRequest(); xhr.open("post", "/casino/slots"); + xhr.setRequestHeader('xhr', 'xhr'); xhr.onload = handleSlotsResponse.bind(null, xhr); const form = new FormData(); diff --git a/files/templates/home.html b/files/templates/home.html index 52ad4e9d8..326ef3cd7 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -210,6 +210,7 @@ var xhr = new XMLHttpRequest(); xhr.withCredentials=true; xhr.open("POST", '/dismiss_mobile_tip', true); + xhr.setRequestHeader('xhr', 'xhr'); xhr.send(); } })