Skip to content

Commit bc7ece0

Browse files
committed
ack PR comments
1 parent 9eda826 commit bc7ece0

File tree

3 files changed

+9
-5
lines changed
  • apps/sim
    • app
      • api/settings/allowed-mcp-domains
      • workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/mcp
    • lib/mcp

3 files changed

+9
-5
lines changed

apps/sim/app/api/settings/allowed-mcp-domains/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { NextResponse } from 'next/server'
2+
import { getSession } from '@/lib/auth'
23
import { getAllowedMcpDomainsFromEnv } from '@/lib/core/config/feature-flags'
34
import { getBaseUrl } from '@/lib/core/utils/urls'
45

56
export async function GET() {
7+
const session = await getSession()
8+
if (!session?.user?.id) {
9+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
10+
}
11+
612
const configuredDomains = getAllowedMcpDomainsFromEnv()
713
if (configuredDomains === null) {
814
return NextResponse.json({ allowedMcpDomains: null })

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/mcp/mcp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function isDomainAllowed(url: string | undefined, allowedDomains: string[] | nul
117117
const hostname = new URL(url).hostname.toLowerCase()
118118
return allowedDomains.includes(hostname)
119119
} catch {
120-
return true
120+
return false
121121
}
122122
}
123123

apps/sim/lib/mcp/domain-check.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ export class McpDomainNotAllowedError extends Error {
99
}
1010

1111
let cachedPlatformHostname: string | null = null
12-
let platformHostnameResolved = false
1312

1413
/**
1514
* Returns the platform's own hostname (from getBaseUrl), lazy-cached.
1615
* Always lowercase. Returns null if the base URL is not configured or invalid.
1716
*/
1817
function getPlatformHostname(): string | null {
19-
if (platformHostnameResolved) return cachedPlatformHostname
20-
platformHostnameResolved = true
18+
if (cachedPlatformHostname !== null) return cachedPlatformHostname
2119
try {
2220
cachedPlatformHostname = new URL(getBaseUrl()).hostname.toLowerCase()
2321
} catch {
24-
cachedPlatformHostname = null
22+
return null
2523
}
2624
return cachedPlatformHostname
2725
}

0 commit comments

Comments
 (0)