Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (server): add support for setting listening host #2604

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function getAllChatFlow(): Promise<IChatFlow[]> {
export async function start(): Promise<void> {
serverApp = new App()

const host = process.env.HOST
const port = parseInt(process.env.PORT || '', 10) || 3000
const server = http.createServer(serverApp.app)

Expand All @@ -208,8 +209,8 @@ export async function start(): Promise<void> {
await serverApp.initDatabase()
await serverApp.config(io)

server.listen(port, () => {
logger.info(`⚡️ [server]: Flowise Server is listening at ${port}`)
server.listen(port, host, () => {
logger.info(`⚡️ [server]: Flowise Server is listening at ${host ? 'http://' + host : ''}:${port}`)
})
}

Expand Down
8 changes: 5 additions & 3 deletions packages/ui/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import dotenv from 'dotenv'
export default defineConfig(async ({ mode }) => {
let proxy = undefined
if (mode === 'development') {
const serverPort = parseInt(dotenv.config({ processEnv: {}, path: '../server/.env' }).parsed?.['PORT'])
const serverEnv = dotenv.config({ processEnv: {}, path: '../server/.env' }).parsed
const serverHost = serverEnv?.['HOST'] ?? 'localhost'
const serverPort = parseInt(serverEnv?.['PORT'] ?? 3000)
if (!Number.isNaN(serverPort) && serverPort > 0 && serverPort < 65535) {
proxy = {
'/api': {
target: `http://localhost:${serverPort}`,
target: `http://${serverHost}:${serverPort}`,
changeOrigin: true
},
'/socket.io': {
target: `http://localhost:${serverPort}`,
target: `http://${serverHost}:${serverPort}`,
changeOrigin: true
}
}
Expand Down
Loading