Added a function which cheks which port to use when port is 443 or 80
This commit is contained in:
parent
247f1e9cb8
commit
609ae8703d
|
|
@ -149,9 +149,12 @@ class Qdrant_VectorStores implements INode {
|
||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const qdrantApiKey = getCredentialParam('qdrantApiKey', credentialData, nodeData)
|
const qdrantApiKey = getCredentialParam('qdrantApiKey', credentialData, nodeData)
|
||||||
|
|
||||||
|
const port = Qdrant_VectorStores.determinePortByUrl(qdrantServerUrl);
|
||||||
|
|
||||||
const client = new QdrantClient({
|
const client = new QdrantClient({
|
||||||
url: qdrantServerUrl,
|
url: qdrantServerUrl,
|
||||||
apiKey: qdrantApiKey
|
apiKey: qdrantApiKey,
|
||||||
|
port: port
|
||||||
})
|
})
|
||||||
|
|
||||||
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
|
|
@ -198,9 +201,12 @@ class Qdrant_VectorStores implements INode {
|
||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const qdrantApiKey = getCredentialParam('qdrantApiKey', credentialData, nodeData)
|
const qdrantApiKey = getCredentialParam('qdrantApiKey', credentialData, nodeData)
|
||||||
|
|
||||||
|
const port = Qdrant_VectorStores.determinePortByUrl(qdrantServerUrl);
|
||||||
|
|
||||||
const client = new QdrantClient({
|
const client = new QdrantClient({
|
||||||
url: qdrantServerUrl,
|
url: qdrantServerUrl,
|
||||||
apiKey: qdrantApiKey
|
apiKey: qdrantApiKey,
|
||||||
|
port: port
|
||||||
})
|
})
|
||||||
|
|
||||||
const dbConfig: QdrantLibArgs = {
|
const dbConfig: QdrantLibArgs = {
|
||||||
|
|
@ -242,6 +248,25 @@ class Qdrant_VectorStores implements INode {
|
||||||
}
|
}
|
||||||
return vectorStore
|
return vectorStore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the port number from the given URL.
|
||||||
|
*
|
||||||
|
* The problem is when not doing this the qdrant-client.js will fall back on 6663 when you enter a port 443 and 80.
|
||||||
|
* See: https://stackoverflow.com/questions/59104197/nodejs-new-url-urlhttps-myurl-com80-lists-the-port-as-empty
|
||||||
|
* @param qdrantServerUrl the url to get the port from
|
||||||
|
*/
|
||||||
|
static determinePortByUrl(qdrantServerUrl: string) :number {
|
||||||
|
let port = 6333;
|
||||||
|
const parsedUrl = new URL(qdrantServerUrl);
|
||||||
|
if (parsedUrl.protocol === 'https:' && parsedUrl.port === '') {
|
||||||
|
port = 443;
|
||||||
|
}
|
||||||
|
if (parsedUrl.protocol === 'http:' && parsedUrl.port === '') {
|
||||||
|
port = 80;
|
||||||
|
}
|
||||||
|
return port;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { nodeClass: Qdrant_VectorStores }
|
module.exports = { nodeClass: Qdrant_VectorStores }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue