Skip to content

Commit e78d3db

Browse files
committed
feat(frontend,core): fix mongodb dns check vs port specify
1 parent 38f4a79 commit e78d3db

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

core/src/plugins/mongodb/db.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ func DB(config *engine.PluginConfig) (*mongo.Client, error) {
1414
ctx := context.Background()
1515
port := common.GetRecordValueOrDefault(config.Credentials.Advanced, "Port", "27017")
1616
queryParams := common.GetRecordValueOrDefault(config.Credentials.Advanced, "URL Params", "")
17+
dnsEnabled := common.GetRecordValueOrDefault(config.Credentials.Advanced, "DNS Enabled", "false")
1718
var connectionString string
18-
// TODO: add TLS enabled logic to work instead of hard coded domains
19-
if config.Credentials.Hostname == "localhost" || config.Credentials.Hostname == "host.docker.internal" {
19+
if dnsEnabled == "false" {
2020
connectionString = fmt.Sprintf("mongodb://%s:%s@%s:%s/%s%s",
2121
config.Credentials.Username,
2222
config.Credentials.Password,

frontend/src/pages/auth/login.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const databaseTypeDropdownItems: IDropdownItem<Record<string, string>>[] = [
4545
id: "MongoDB",
4646
label: "MongoDB",
4747
icon: Icons.Logos.MongoDB,
48-
extra: {"Port": "27017", "URL Params": "?"},
48+
extra: {"Port": "27017", "URL Params": "?", "DNS Enabled": "false"},
4949
},
5050
{
5151
id: "Redis",
@@ -168,10 +168,13 @@ export const LoginPage: FC = () => {
168168
setUsername(url.username);
169169
setPassword(url.password);
170170
setDatabase(url.pathname.substring(1));
171-
setAdvancedForm({ "Port": url.port.length > 0 ? url.port : "80", "URL Params": `?${url.searchParams.toString()}` });
172-
if (url.port != null || url.searchParams.size !== 0) {
173-
setShowAdvanced(true);
171+
const advancedForm = { "Port": "27017", "URL Params": `?${url.searchParams.toString()}`, "DNS Enabled": "false" };
172+
if (url.port.length === 0) {
173+
advancedForm["Port"] = "";
174+
advancedForm["DNS Enabled"] = "true";
174175
}
176+
setAdvancedForm(advancedForm);
177+
setShowAdvanced(true);
175178
}, [databaseType.id]);
176179

177180
const fields = useMemo(() => {

0 commit comments

Comments
 (0)