Skip to content

Commit df7e1da

Browse files
authored
Merge pull request #4112 from manalkaff/fix/mongodb-connection-url-missing-auth-params
fix: add authSource and directConnection params to MongoDB connection URLs
2 parents df9aa50 + d9b2b48 commit df7e1da

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

apps/dokploy/components/dashboard/mongo/general/show-external-mongo-credentials.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export const ShowExternalMongoCredentials = ({ mongoId }: Props) => {
8282
const buildConnectionUrl = () => {
8383
const port = form.watch("externalPort") || data?.externalPort;
8484

85-
return `mongodb://${data?.databaseUser}:${data?.databasePassword}@${getIp}:${port}`;
85+
const params = `authSource=admin${data?.replicaSets ? "" : "&directConnection=true"}`;
86+
return `mongodb://${data?.databaseUser}:${data?.databasePassword}@${getIp}:${port}/?${params}`;
8687
};
8788

8889
setConnectionUrl(buildConnectionUrl());

apps/dokploy/components/dashboard/mongo/general/show-internal-mongo-credentials.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const ShowInternalMongoCredentials = ({ mongoId }: Props) => {
6262
<Label>Internal Connection URL </Label>
6363
<ToggleVisibilityInput
6464
disabled
65-
value={`mongodb://${data?.databaseUser}:${data?.databasePassword}@${data?.appName}:27017`}
65+
value={`mongodb://${data?.databaseUser}:${data?.databasePassword}@${data?.appName}:27017/?authSource=admin${data?.replicaSets ? "" : "&directConnection=true"}`}
6666
/>
6767
</div>
6868
</div>

0 commit comments

Comments
 (0)