diff --git a/ui/src/index.tsx b/ui/src/index.tsx index 6f244b19..02caa06e 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -13,9 +13,6 @@ import {loadStoredTheme} from './store/ui-actions.ts'; import {Provider} from 'react-redux'; import store from './store/index'; -// the development server of vite will proxy this to the backend -const devUrl = '/api/'; - const {port, hostname, protocol, pathname} = window.location; const slashes = protocol.concat('//'); const path = pathname.endsWith('/') ? pathname : pathname.substring(0, pathname.lastIndexOf('/')); @@ -25,10 +22,8 @@ const urlWithSlash = url.endsWith('/') ? url : url.concat('/'); const prodUrl = urlWithSlash; const clientJS = async () => { - if (import.meta.env.MODE === 'production') { - config.set('url', prodUrl); - } else { - config.set('url', devUrl); + config.set('url', prodUrl); + if (import.meta.env.MODE !== 'production') { config.set('register', true); } diff --git a/ui/vite.config.ts b/ui/vite.config.ts index 84adfb21..fb6bf080 100644 --- a/ui/vite.config.ts +++ b/ui/vite.config.ts @@ -66,16 +66,14 @@ export default defineConfig({ server: { host: '0.0.0.0', proxy: { - '/api': { + '^/(application|message|client|current|user|plugin|version|image)': { target: 'http://localhost:3000/', changeOrigin: true, secure: false, - rewrite: (p) => p.replace(/^\/api/, ''), }, - '/api/stream': { + '/stream': { target: 'ws://localhost:3000/', ws: true, - rewrite: (p) => p.replace(/^\/api/, ''), rewriteWsOrigin: true, } }, @@ -83,16 +81,14 @@ export default defineConfig({ }, preview: { proxy: { - '/api': { + '^/(application|message|client|current|user|plugin|version)': { target: 'http://localhost:3000/', changeOrigin: true, secure: false, - rewrite: (p) => p.replace(/^\/api/, ''), }, - '/api/stream': { + '/stream': { target: 'ws://localhost:3000/', ws: true, - rewrite: (p) => p.replace(/^\/api/, ''), rewriteWsOrigin: true, } },