From 75e42359738d12720d963fcf93d2355c16d46aee Mon Sep 17 00:00:00 2001 From: Jacob Bare Date: Wed, 16 Oct 2019 13:53:49 -0500 Subject: [PATCH] Change apiHost to baseApiUri The `baseApiUri` parameter, if not provided, will now use `window.location.origin` as the default value (instead of `hostname`). --- demo.html | 2 +- src/apollo/create-provider.js | 10 +++++----- src/config.js | 4 ++-- src/main.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/demo.html b/demo.html index 9491e04..f0d4706 100644 --- a/demo.html +++ b/demo.html @@ -8,7 +8,7 @@ bmc.configure({ graphqlUri: 'http://0.0.0.0:11001', tenantKey: 'acbm_fcp', - apiHost: 'manage.forconstructionpros.com' + baseApiUri: 'https://manage.forconstructionpros.com' }); diff --git a/src/apollo/create-provider.js b/src/apollo/create-provider.js index ee5a59c..82494e6 100644 --- a/src/apollo/create-provider.js +++ b/src/apollo/create-provider.js @@ -1,14 +1,14 @@ import VueApollo from 'vue-apollo'; import createApolloClient from './create-client'; -export default ({ graphqlUri, tenantKey, apiHost } = {}) => { - const host = apiHost || window.location.hostname; - if (!graphqlUri || !tenantKey || !host) { - throw new Error('The graphqlUri, tenantKey, and apiHost options are required to create the BaseCMS Apollo Provider.'); +export default ({ graphqlUri, tenantKey, baseApiUri } = {}) => { + const apiUri = baseApiUri || window.location.origin; + if (!graphqlUri || !tenantKey || !apiUri) { + throw new Error('The graphqlUri, tenantKey, and baseApiUri options are required to create the BaseCMS Apollo Provider.'); } const headers = { 'x-tenant-key': tenantKey, - 'x-base4-api-hostname': apiHost || window.location.hostname, + 'x-base4-api-uri': apiUri, }; return new VueApollo({ defaultClient: createApolloClient({ uri: graphqlUri, headers }), diff --git a/src/config.js b/src/config.js index f8e45c2..4a46c19 100644 --- a/src/config.js +++ b/src/config.js @@ -15,11 +15,11 @@ const getApolloProvider = () => { }; const configure = (options = {}) => { - const { graphqlUri, tenantKey, apiHost } = options; + const { graphqlUri, tenantKey, baseApiUri } = options; if (hasConfigured()) { warn('BaseCMS components have already been configured. The following config changes will NOT be applied.', options); } else { - apolloProvider = createProvider({ graphqlUri, tenantKey, apiHost }); + apolloProvider = createProvider({ graphqlUri, tenantKey, baseApiUri }); config = options; } }; diff --git a/src/main.js b/src/main.js index 8bf8167..b37e329 100644 --- a/src/main.js +++ b/src/main.js @@ -9,7 +9,7 @@ Vue.config.productionTip = false; configure({ graphqlUri: 'http://0.0.0.0:11001', tenantKey: 'acbm_fcp', - apiHost: 'manage.forconstructionpros.com', + baseApiUri: 'https://manage.forconstructionpros.com', }); new Vue({