From 26b47438c60a673bf500728e7236d0dcd5173438 Mon Sep 17 00:00:00 2001 From: Jerome Date: Mon, 24 Feb 2025 10:39:38 +0000 Subject: [PATCH] Tidy up CORS error catching --- src/client/auth.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/client/auth.ts b/src/client/auth.ts index 5f5c860e..c7799429 100644 --- a/src/client/auth.ts +++ b/src/client/auth.ts @@ -170,11 +170,12 @@ export async function discoverOAuthMetadata( "MCP-Protocol-Version": opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION } }); - } catch { - try { + } catch (error) { + // CORS errors come back as TypeError + if (error instanceof TypeError) { response = await fetch(url); - } catch { - return undefined; + } else { + throw error; } }