From ec81d28a7767f8dc7863114e9436098af751cd0e Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 20 Jun 2022 10:44:01 +0200 Subject: [PATCH] [frontend] add Accept header to oauthed api requests (#657) --- web/source/lib/oauth.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/source/lib/oauth.js b/web/source/lib/oauth.js index 673d4ce83..9cbf3d484 100644 --- a/web/source/lib/oauth.js +++ b/web/source/lib/oauth.js @@ -149,7 +149,7 @@ module.exports = function oauthClient(config, initState) { return (state.access_token != undefined); } - function apiRequest(path, method, data, type="json") { + function apiRequest(path, method, data, type="json", accept="json") { if (!isAuthorized()) { throw new Error("Not Authenticated"); } @@ -160,7 +160,8 @@ module.exports = function oauthClient(config, initState) { url.search = s; } let headers = { - "Authorization": `Bearer ${state.access_token}` + "Authorization": `Bearer ${state.access_token}`, + "Accept": accept == "json" ? "application/json" : "*/*" }; let body = data; if (type == "json" && body != undefined) {