Skip to content

Commit

Permalink
[frontend] add Accept header to oauthed api requests (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmethurst authored Jun 20, 2022
1 parent 610395d commit ec81d28
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions web/source/lib/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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) {
Expand Down

0 comments on commit ec81d28

Please sign in to comment.