aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/mixins
diff options
context:
space:
mode:
authorEvan Steinkerchner <esteinkerchner@gmail.com>2022-04-27 19:15:18 -0400
committerEvan Steinkerchner <esteinkerchner@gmail.com>2022-04-27 19:15:18 -0400
commitd48fc7ca2625b7e645ed0ab9b349bfc1876016aa (patch)
tree5a59581b8e087b760541191363a0592bc5ad7077 /src/mixins
parent2da071d0ea2fd29ddb7515f6bf702947398e1dbd (diff)
downloadhomer-d48fc7ca2625b7e645ed0ab9b349bfc1876016aa.tar.gz
homer-d48fc7ca2625b7e645ed0ab9b349bfc1876016aa.tar.zst
homer-d48fc7ca2625b7e645ed0ab9b349bfc1876016aa.zip
Revert "Added url and apikey config options under proxy"
This reverts commit a2dfffab6892c6976fc8b880f75c314506259675.
Diffstat (limited to 'src/mixins')
-rw-r--r--src/mixins/service.js20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/mixins/service.js b/src/mixins/service.js
index b47f756..abc708c 100644
--- a/src/mixins/service.js
+++ b/src/mixins/service.js
@@ -1,5 +1,3 @@
1const merge = require("lodash.merge");
2
3export default { 1export default {
4 props: { 2 props: {
5 proxy: Object, 3 proxy: Object,
@@ -27,28 +25,18 @@ export default {
27 this.item.useCredentials === true ? "include" : "omit"; 25 this.item.useCredentials === true ? "include" : "omit";
28 } 26 }
29 27
30 if (this.proxy?.apikey) { 28 options = Object.assign(options, init);
31 options.headers = {
32 "X-Homer-Api-Key": this.proxy.apikey,
33 };
34 }
35 29
36 if (path.startsWith("/")) { 30 if (path.startsWith("/")) {
37 path = path.slice(1); 31 path = path.slice(1);
38 } 32 }
39 33
40 let url = path ? `${this.endpoint}/${path}` : this.endpoint; 34 let url = this.endpoint;
41 35
42 if (this.proxy?.url) { 36 if (path) {
43 options.headers = { 37 url = `${this.endpoint}/${path}`;
44 ...(options.headers || {}),
45 "X-Homer-Api-Url": url,
46 };
47 url = this.proxy.url;
48 } 38 }
49 39
50 options = merge(options, init);
51
52 return fetch(url, options).then((response) => { 40 return fetch(url, options).then((response) => {
53 if (!response.ok) { 41 if (!response.ok) {
54 throw new Error("Not 2xx response"); 42 throw new Error("Not 2xx response");