Skip to content

Commit 34251fa

Browse files
authored
Bugfix - Add x-forwarded-proto as source for http protocol for base url and add base url field to ChatflowTool (FlowiseAI#2592)
1 parent cb93d9d commit 34251fa

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ChatflowTool_Tools implements INode {
2222
constructor() {
2323
this.label = 'Chatflow Tool'
2424
this.name = 'ChatflowTool'
25-
this.version = 1.0
25+
this.version = 2.0
2626
this.type = 'ChatflowTool'
2727
this.icon = 'chatflowTool.svg'
2828
this.category = 'Tools'
@@ -56,6 +56,16 @@ class ChatflowTool_Tools implements INode {
5656
placeholder:
5757
'State of the Union QA - useful for when you need to ask questions about the most recent state of the union address.'
5858
},
59+
{
60+
label: 'Base URL',
61+
name: 'baseURL',
62+
type: 'string',
63+
description:
64+
'Base URL to Flowise. By default, it is the URL of the incoming request. Useful when you need to execute the Chatflow through an alternative route.',
65+
placeholder: 'http://localhost:3000',
66+
optional: true,
67+
additionalParams: true
68+
},
5969
{
6070
label: 'Use Question from Chat',
6171
name: 'useQuestionFromChat',
@@ -107,7 +117,7 @@ class ChatflowTool_Tools implements INode {
107117
const useQuestionFromChat = nodeData.inputs?.useQuestionFromChat as boolean
108118
const customInput = nodeData.inputs?.customInput as string
109119

110-
const baseURL = options.baseURL as string
120+
const baseURL = (nodeData.inputs?.baseURL as string) || (options.baseURL as string)
111121

112122
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
113123
const chatflowApiKey = getCredentialParam('chatflowApiKey', credentialData, nodeData)

packages/server/src/utils/buildChatflow.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export const utilBuildChatflow = async (req: Request, socketIO?: Server, isInter
5454
try {
5555
const appServer = getRunningExpressApp()
5656
const chatflowid = req.params.id
57-
const baseURL = `${req.protocol}://${req.get('host')}`
57+
58+
const httpProtocol = req.get('x-forwarded-proto') || req.protocol
59+
const baseURL = `${httpProtocol}://${req.get('host')}`
5860

5961
let incomingInput: IncomingInput = req.body
6062
let nodeToExecuteData: INodeData

0 commit comments

Comments
 (0)