From 58f9b964745e7e6be6e48e870eab83ba8dcbfc98 Mon Sep 17 00:00:00 2001 From: kissel Date: Thu, 11 Jul 2024 13:56:15 +0200 Subject: [PATCH] add X-Requested-With header to fetch() requests --- CHANGELOG.md | 2 ++ src/cadenza.js | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc3cde60..625c3edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Fixed +- Make Cadenza return an error instead of showing an error page. ## 2.10.0 - 2024-06-11 ### Added diff --git a/src/cadenza.js b/src/cadenza.js index b2b51e13..c9827807 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -851,7 +851,13 @@ export class CadenzaClient { ) { const url = this.#createUrl(path, params); this.#log('Fetch', url.toString()); - const res = await fetch(url, { signal }); + const res = await fetch(url, { + signal, + headers: { + // Make Cadenza return an error instead of showing an error page. + 'X-Requested-With': 'XMLHttpRequest' + } + }); if (!res.ok) { const errorType = {