From e641b319f70be7cbc4a2623a2967f403c7ea9d52 Mon Sep 17 00:00:00 2001 From: Frederik Kriewitz Date: Tue, 13 Feb 2024 09:41:25 +0100 Subject: [PATCH] make server url configurable in dev mode --- client/components/covers/AuthorImage.vue | 4 ---- client/components/modals/rssfeed/OpenCloseModal.vue | 1 - client/nuxt.config.js | 8 ++++---- client/pages/audiobook/_id/chapters.vue | 3 --- client/store/globals.js | 7 ------- 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/client/components/covers/AuthorImage.vue b/client/components/covers/AuthorImage.vue index c3cafaea0..ca51df255 100644 --- a/client/components/covers/AuthorImage.vue +++ b/client/components/covers/AuthorImage.vue @@ -56,10 +56,6 @@ export default { }, imgSrc() { if (!this.imagePath) return null - if (process.env.NODE_ENV !== 'production') { - // Testing - return `http://localhost:3333${this.$config.routerBasePath}/api/authors/${this.authorId}/image?token=${this.userToken}&ts=${this.updatedAt}` - } return `/api/authors/${this.authorId}/image?token=${this.userToken}&ts=${this.updatedAt}` } }, diff --git a/client/components/modals/rssfeed/OpenCloseModal.vue b/client/components/modals/rssfeed/OpenCloseModal.vue index c4ec909cc..fcb801d96 100644 --- a/client/components/modals/rssfeed/OpenCloseModal.vue +++ b/client/components/modals/rssfeed/OpenCloseModal.vue @@ -139,7 +139,6 @@ export default { slug: this.newFeedSlug, metadataDetails: this.metadataDetails } - if (this.$isDev) payload.serverAddress = `http://localhost:3333${this.$config.routerBasePath}` console.log('Payload', payload) this.$axios diff --git a/client/nuxt.config.js b/client/nuxt.config.js index 1736e3f68..58afeb1b0 100644 --- a/client/nuxt.config.js +++ b/client/nuxt.config.js @@ -6,7 +6,7 @@ module.exports = { target: 'static', dev: process.env.NODE_ENV !== 'production', env: { - serverUrl: process.env.NODE_ENV === 'production' ? process.env.ROUTER_BASE_PATH || '' : 'http://localhost:3333', + serverUrl: process.env.NODE_ENV === 'production' ? process.env.ROUTER_BASE_PATH || '' : process.env.DEV_SERVER_URL || 'http://localhost:3333', chromecastReceiver: 'FD1F76C5' }, telemetry: false, @@ -70,14 +70,14 @@ module.exports = { ], proxy: { - '/api/': { target: process.env.NODE_ENV !== 'production' ? 'http://localhost:3333' : '/' }, - '/dev/': { target: 'http://localhost:3333', pathRewrite: { '^/dev/': '' } } + '/api/': { target: process.env.NODE_ENV !== 'production' ? process.env.DEV_SERVER_URL || 'http://localhost:3333' : '/' }, + '/dev/': { target: process.env.DEV_SERVER_URL || 'http://localhost:3333', pathRewrite: { '^/dev/': '' } } }, io: { sockets: [{ name: 'dev', - url: 'http://localhost:3333' + url: process.env.DEV_SERVER_URL || 'http://localhost:3333' }, { name: 'prod' diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index cf48ab641..24fb243f6 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -414,9 +414,6 @@ export default { const audioEl = this.audioEl || document.createElement('audio') var src = audioTrack.contentUrl + `?token=${this.userToken}` - if (this.$isDev) { - src = `http://localhost:3333${this.$config.routerBasePath}${src}` - } audioEl.src = src audioEl.id = 'chapter-audio' diff --git a/client/store/globals.js b/client/store/globals.js index 32d58c965..ec6082b74 100644 --- a/client/store/globals.js +++ b/client/store/globals.js @@ -95,19 +95,12 @@ export const getters = { const lastUpdate = libraryItem.updatedAt || Date.now() const libraryItemId = libraryItem.libraryItemId || libraryItem.id // Workaround for /users/:id page showing media progress covers - if (process.env.NODE_ENV !== 'production') { // Testing - return `http://localhost:3333${rootState.routerBasePath}/api/items/${libraryItemId}/cover?token=${userToken}&ts=${lastUpdate}${raw ? '&raw=1' : ''}` - } - return `${rootState.routerBasePath}/api/items/${libraryItemId}/cover?token=${userToken}&ts=${lastUpdate}${raw ? '&raw=1' : ''}` }, getLibraryItemCoverSrcById: (state, getters, rootState, rootGetters) => (libraryItemId, timestamp = null, raw = false) => { const placeholder = `${rootState.routerBasePath}/book_placeholder.jpg` if (!libraryItemId) return placeholder const userToken = rootGetters['user/getToken'] - if (process.env.NODE_ENV !== 'production') { // Testing - return `http://localhost:3333${rootState.routerBasePath}/api/items/${libraryItemId}/cover?token=${userToken}${raw ? '&raw=1' : ''}${timestamp ? `&ts=${timestamp}` : ''}` - } return `${rootState.routerBasePath}/api/items/${libraryItemId}/cover?token=${userToken}${raw ? '&raw=1' : ''}${timestamp ? `&ts=${timestamp}` : ''}` }, getIsBatchSelectingMediaItems: (state) => {