Skip to content

Commit

Permalink
Use the same url while working in dev mode compared to production mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mfechner committed Jan 6, 2025
1 parent 187c776 commit 09dbb25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
9 changes: 2 additions & 7 deletions ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('/'));
Expand All @@ -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);
}

Expand Down
12 changes: 4 additions & 8 deletions ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,29 @@ 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,
}
},
cors: false,
},
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,
}
},
Expand Down

0 comments on commit 09dbb25

Please sign in to comment.