Skip to content

Commit

Permalink
Bugfix - Add x-forwarded-proto as source for http protocol for base u…
Browse files Browse the repository at this point in the history
…rl and add base url field to ChatflowTool (FlowiseAI#2592)
  • Loading branch information
danieldabate authored Jun 7, 2024
1 parent cb93d9d commit 34251fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ChatflowTool_Tools implements INode {
constructor() {
this.label = 'Chatflow Tool'
this.name = 'ChatflowTool'
this.version = 1.0
this.version = 2.0
this.type = 'ChatflowTool'
this.icon = 'chatflowTool.svg'
this.category = 'Tools'
Expand Down Expand Up @@ -56,6 +56,16 @@ class ChatflowTool_Tools implements INode {
placeholder:
'State of the Union QA - useful for when you need to ask questions about the most recent state of the union address.'
},
{
label: 'Base URL',
name: 'baseURL',
type: 'string',
description:
'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.',
placeholder: 'http://localhost:3000',
optional: true,
additionalParams: true
},
{
label: 'Use Question from Chat',
name: 'useQuestionFromChat',
Expand Down Expand Up @@ -107,7 +117,7 @@ class ChatflowTool_Tools implements INode {
const useQuestionFromChat = nodeData.inputs?.useQuestionFromChat as boolean
const customInput = nodeData.inputs?.customInput as string

const baseURL = options.baseURL as string
const baseURL = (nodeData.inputs?.baseURL as string) || (options.baseURL as string)

const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const chatflowApiKey = getCredentialParam('chatflowApiKey', credentialData, nodeData)
Expand Down
4 changes: 3 additions & 1 deletion packages/server/src/utils/buildChatflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export const utilBuildChatflow = async (req: Request, socketIO?: Server, isInter
try {
const appServer = getRunningExpressApp()
const chatflowid = req.params.id
const baseURL = `${req.protocol}://${req.get('host')}`

const httpProtocol = req.get('x-forwarded-proto') || req.protocol
const baseURL = `${httpProtocol}://${req.get('host')}`

let incomingInput: IncomingInput = req.body
let nodeToExecuteData: INodeData
Expand Down

0 comments on commit 34251fa

Please sign in to comment.