feat(ui): auto proxy backend (#2238)
This commit is contained in:
parent
f378dcc332
commit
4782c0f6fc
|
|
@ -4,10 +4,7 @@ export const drawerWidth = 260
|
|||
export const appDrawerWidth = 320
|
||||
export const headerHeight = 80
|
||||
export const maxScroll = 100000
|
||||
export const baseURL =
|
||||
import.meta.env.PROD === true
|
||||
? window.location.origin
|
||||
: window.location.origin.replace(`:${import.meta.env.VITE_PORT ?? '8080'}`, ':3000')
|
||||
export const baseURL = window.location.origin
|
||||
export const uiBaseURL = window.location.origin
|
||||
export const FLOWISE_CREDENTIAL_ID = 'FLOWISE_CREDENTIAL_ID'
|
||||
export const REDACTED_CREDENTIAL_VALUE = '_FLOWISE_BLANK_07167752-1a71-43b1-bf8f-4f32252165db'
|
||||
|
|
|
|||
|
|
@ -3,21 +3,36 @@ import react from '@vitejs/plugin-react'
|
|||
import { resolve } from 'path'
|
||||
import dotenv from 'dotenv'
|
||||
|
||||
dotenv.config()
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'src')
|
||||
export default defineConfig(async ({ mode }) => {
|
||||
let proxy = undefined
|
||||
if (mode === 'development') {
|
||||
const serverPort = parseInt(dotenv.config({ processEnv: {}, path: '../server/.env' }).parsed?.['PORT'])
|
||||
if (!Number.isNaN(serverPort) && serverPort > 0 && serverPort < 65535) {
|
||||
proxy = {
|
||||
'/api': {
|
||||
target: `http://localhost:${serverPort}`,
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dotenv.config()
|
||||
return {
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'src')
|
||||
}
|
||||
},
|
||||
root: resolve(__dirname),
|
||||
build: {
|
||||
outDir: './build'
|
||||
},
|
||||
server: {
|
||||
open: true,
|
||||
proxy,
|
||||
port: process.env.VITE_PORT ?? 8080,
|
||||
host: process.env.VITE_HOST
|
||||
}
|
||||
},
|
||||
root: resolve(__dirname),
|
||||
build: {
|
||||
outDir: './build'
|
||||
},
|
||||
server: {
|
||||
open: true,
|
||||
port: process.env.VITE_PORT ?? 8080
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue