Tidy up CORS error catching

This commit is contained in:
Jerome 2025-02-24 10:39:38 +00:00
commit 26b47438c6
No known key found for this signature in database

View file

@ -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;
}
}