diff --git a/src/api/rest-axios.js b/src/api/rest-axios.js index 1efa49a..46c9f6c 100644 --- a/src/api/rest-axios.js +++ b/src/api/rest-axios.js @@ -16,7 +16,7 @@ import axios from 'axios' // let path = 'http://' + window.location.hostname + (window.env === 'prod' ? '/api' : ':8984') export const REST = axios.create({ - baseURL: 'http://' + window.location.hostname + (window.env === 'prod' ? '/api' : ':8984'), + baseURL: 'http://' + window.location.hostname, // withCredentials: true, crossorigin: true, headers: { diff --git a/src/index.js b/src/index.js index 95ce619..7e40685 100644 --- a/src/index.js +++ b/src/index.js @@ -30,7 +30,8 @@ Vue.use(InfiniteLoading, { Vue.use(VueScrollTo) -window.env = process.env +// window.env = process.env +window.apipath = process.env === 'prod' ? '/api' : ':8984' // sync(store, router) // done. Returns an unsync callback fn diff --git a/src/pages/Bibliographie.vue b/src/pages/Bibliographie.vue index 5f2be3c..3bb237e 100644 --- a/src/pages/Bibliographie.vue +++ b/src/pages/Bibliographie.vue @@ -21,7 +21,7 @@ export default { }), beforeCreate () { // ?_format=json - REST.get(`/bibliography/works`, {}) + REST.get(`${apipath}/bibliography/works`, {}) .then(({ data }) => { console.log('Biblio REST: data', data) // if(data.length){ diff --git a/src/pages/Edition.vue b/src/pages/Edition.vue index 3016a06..c06382d 100644 --- a/src/pages/Edition.vue +++ b/src/pages/Edition.vue @@ -126,7 +126,7 @@ export default { console.log('texts this.$route', this.$route) // http://localhost:8984/texts/gdpSauval1724/toc // get the edition's toc - REST.get(`/texts/` + this.$route.params.id + `/toc`, {}) + REST.get(`${apipath}/texts/` + this.$route.params.id + `/toc`, {}) .then(({ data }) => { console.log('texts/toc REST: data', data) this.meta = data.meta @@ -194,7 +194,7 @@ export default { }), getTextContent (textid, $state = null, direction = 'next') { console.log('getTextContent', textid) - REST.get(`/items/${textid}`, {}) + REST.get(`${apipath}/items/${textid}`, {}) .then(({ data }) => { console.log('text REST: data', data) if (direction === 'next') { @@ -248,7 +248,7 @@ export default { }, getIndexItem (item) { this.indexitem = 'loading' - REST.get(`/index${item.index.charAt(0).toUpperCase()}${item.index.slice(1)}/${item.uuid}`, {}) + REST.get(`${apipath}/index${item.index.charAt(0).toUpperCase()}${item.index.slice(1)}/${item.uuid}`, {}) .then(({ data }) => { console.log('index tooltip REST: data', data) if (this.indexitem === 'loading') { diff --git a/src/pages/IndexLocorum.vue b/src/pages/IndexLocorum.vue index 876777f..c69815f 100644 --- a/src/pages/IndexLocorum.vue +++ b/src/pages/IndexLocorum.vue @@ -34,7 +34,7 @@ export default { items: [] }), beforeCreate () { - REST.get(`/indexLocorum`, {}) + REST.get(`${apipath}/indexLocorum`, {}) .then(({ data }) => { console.log('index locorum REST: data', data) if (data.content.length) { diff --git a/src/pages/IndexNominum.vue b/src/pages/IndexNominum.vue index 610e775..c80e074 100644 --- a/src/pages/IndexNominum.vue +++ b/src/pages/IndexNominum.vue @@ -37,7 +37,7 @@ export default { beforeCreate () { // items/gdpLeMaire1685T01BodyFr01.003.016 // texts/gdpSauval1724 - REST.get(`/indexNominum`, {}) + REST.get(`${apipath}/indexNominum`, {}) .then(({ data }) => { console.log('index nominum REST: data', data) if (data.content.length) { diff --git a/src/pages/IndexOperum.vue b/src/pages/IndexOperum.vue index 52ce111..ab73a62 100644 --- a/src/pages/IndexOperum.vue +++ b/src/pages/IndexOperum.vue @@ -34,7 +34,7 @@ export default { items: [] }), beforeCreate () { - REST.get(`/indexOperum`, {}) + REST.get(`${apipath}/indexOperum`, {}) .then(({ data }) => { console.log('index operum REST: data', data) if (data.content.length) { diff --git a/src/pages/Item.vue b/src/pages/Item.vue index 044baed..ab4c71b 100644 --- a/src/pages/Item.vue +++ b/src/pages/Item.vue @@ -49,7 +49,7 @@ export default { methods: { loadItem () { this.loaded = false - REST.get(`/items/` + this.uuid, {}) + REST.get(`${apipath}/items/` + this.uuid, {}) .then(({ data }) => { console.log('item REST: data', data) this.item = data.content diff --git a/src/pages/Locorum.vue b/src/pages/Locorum.vue index e529491..6c0bd0d 100644 --- a/src/pages/Locorum.vue +++ b/src/pages/Locorum.vue @@ -41,7 +41,7 @@ export default { }, beforeCreate () { console.log('locorum this.$route', this.$route) - REST.get(`/indexLocorum/` + this.$route.params.id, {}) + REST.get(`${apipath}/indexLocorum/` + this.$route.params.id, {}) .then(({ data }) => { console.log('locorum REST: data', data) if (data.content) { diff --git a/src/pages/Nominum.vue b/src/pages/Nominum.vue index bd834ac..783b97e 100644 --- a/src/pages/Nominum.vue +++ b/src/pages/Nominum.vue @@ -40,7 +40,7 @@ export default { }, beforeCreate () { console.log('nominum this.$route', this.$route) - REST.get(`/indexNominum/` + this.$route.params.id, {}) + REST.get(`${apipath}/indexNominum/` + this.$route.params.id, {}) .then(({ data }) => { console.log('nominum REST: data', data) if (data.content) { diff --git a/src/pages/Operum.vue b/src/pages/Operum.vue index 644e4c2..ec6562f 100644 --- a/src/pages/Operum.vue +++ b/src/pages/Operum.vue @@ -36,7 +36,7 @@ export default { }, beforeCreate () { console.log('operum this.$route', this.$route) - REST.get(`/indexOperum/` + this.$route.params.id, {}) + REST.get(`${apipath}/indexOperum/` + this.$route.params.id, {}) .then(({ data }) => { console.log('operum REST: data', data) if (data.content) { diff --git a/src/store/modules/corpus.js b/src/store/modules/corpus.js index 9518449..030f42e 100644 --- a/src/store/modules/corpus.js +++ b/src/store/modules/corpus.js @@ -57,7 +57,7 @@ export default { }, // get authors getAuthors ({ dispatch, commit, state }) { - return REST.get(`/corpus`, {}) + return REST.get(`${apipath}/corpus`, {}) // .then(({ data }) => { // console.log('corpus getAuthors REST: data', data) // commit('setAuthors', data.content) @@ -70,7 +70,7 @@ export default { // get editionslist getEditionsList ({ dispatch, commit, state }, authors) { return Promise.all(authors.map(function (author) { - return REST.get(`/corpus/` + author.uuid, {}) + return REST.get(`${apipath}/corpus/` + author.uuid, {}) .then(({ data }) => { console.log('corpus getEditionsList REST: author, data', author, data) // work arround diff --git a/src/store/modules/search.js b/src/store/modules/search.js index 2714353..a21f586 100644 --- a/src/store/modules/search.js +++ b/src/store/modules/search.js @@ -41,7 +41,7 @@ export default { } // console.log('Search getResults params', params); let q = qs.stringify(params) - return REST.get(`/search?` + q) + return REST.get(`${apipath}/search?` + q) .then(({ data }) => { console.log('search REST: data', data) commit('setIsloading', false)