From 56d1279584a03a5eab3c0428b1bdb65b1a185d95 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Mon, 24 May 2021 13:35:36 +0200 Subject: [PATCH] Allow `api` action to make arbitrary HTTP(S) requests. If the URL is an absolute HTTP(S) one, we use it as-is. --- lib/www/client/source/src/store/modules/api/actions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/www/client/source/src/store/modules/api/actions.js b/lib/www/client/source/src/store/modules/api/actions.js index 8a0a485..68bc7e1 100644 --- a/lib/www/client/source/src/store/modules/api/actions.js +++ b/lib/www/client/source/src/store/modules/api/actions.js @@ -13,7 +13,8 @@ async function api ({state, commit, dispatch}, [resource, init = {}, cb]) { init.body = JSON.stringify(init.body); } } - const res = await fetch(`${state.apiUrl}${resource}`, init); + const url = /^https?:\/\//i.test(resource) ? resource : (state.apiUrl + resource); + const res = await fetch(url, init); if (typeof cb === 'function') { cb(null, res); }