refactor widget api design

this passes all widget API calls through the backend, with a pluggable design and reusable API handlers
This commit is contained in:
Ben Phelps committed 2022-09-04 21:58:42 +03:00
1 parent 975f79f6cc
commit 97bf174b78
27 files changed
+370 -252

No files matched your search

+17
View File
@@ -44,3 +44,20 @@ export function httpRequest(url, params) {
request.end();
});
}
export function httpProxy(url, params = {}) {
const constructedUrl = new URL(url);
if (constructedUrl.protocol === "https:") {
const httpsAgent = new https.Agent({
rejectUnauthorized: false,
});
return httpsRequest(constructedUrl, {
agent: httpsAgent,
...params,
});
} else {
return httpRequest(constructedUrl, params);
}
}