🐛 fix(skill): skip OAuth redirectUri on desktop to prevent broken app (#14345)

🐛 fix(skill): skip OAuth redirectUri on desktop to prevent broken app:// navigation

On desktop (Electron), window.location.origin is app://renderer which the system browser cannot navigate to. Skip passing redirectUri so market shows a default success page instead, relying on existing window-close monitoring and fallback polling to detect OAuth completion.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
LiJian
2026-05-01 13:00:55 +08:00
committed by GitHub
parent 8c3b83f8b3
commit d0091901dc
5 changed files with 22 additions and 6 deletions
@@ -872,8 +872,9 @@ export class AgentManagerRuntime {
}
// Need OAuth authorization
// Skip redirectUri on desktop (app:// protocol) since the system browser can't navigate to it
const redirectUri =
typeof window !== 'undefined'
typeof window !== 'undefined' && window.location.protocol.startsWith('http')
? `${window.location.origin}/oauth/callback/success?provider=${encodeURIComponent(identifier)}`
: undefined;
const authInfo = await getToolStoreState().getLobehubSkillAuthorizeUrl(identifier, {
@@ -191,7 +191,11 @@ class CredsExecutor extends BaseExecutor<typeof CredsApiName> {
}
// Get the authorization URL from the market API
const redirectUri = `${typeof window !== 'undefined' ? window.location.origin : ''}/oauth/callback/success?provider=${provider}`;
// Skip redirectUri on desktop (app:// protocol) since the system browser can't navigate to it
const redirectUri =
typeof window !== 'undefined' && window.location.protocol.startsWith('http')
? `${window.location.origin}/oauth/callback/success?provider=${provider}`
: undefined;
const response = await toolsClient.market.connectGetAuthorizeUrl.query({
provider,
redirectUri,
@@ -201,7 +201,10 @@ const LobehubSkillServerItem = memo<LobehubSkillServerItemProps>(({ provider, la
setIsConnecting(true);
try {
// Use /oauth/callback/success as redirect URI with provider param for auto-enable
const redirectUri = `${window.location.origin}/oauth/callback/success?provider=${encodeURIComponent(provider)}`;
// Skip redirectUri on desktop (app:// protocol) since the system browser can't navigate to it
const redirectUri = window.location.protocol.startsWith('http')
? `${window.location.origin}/oauth/callback/success?provider=${encodeURIComponent(provider)}`
: undefined;
const { authorizeUrl } = await getAuthorizeUrl(provider, { redirectUri });
openOAuthWindow(authorizeUrl);
} catch (error) {
@@ -277,7 +280,9 @@ const LobehubSkillServerItem = memo<LobehubSkillServerItemProps>(({ provider, la
onClick={async (e) => {
e.stopPropagation();
try {
const redirectUri = `${window.location.origin}/oauth/callback/success?provider=${encodeURIComponent(provider)}`;
const redirectUri = window.location.protocol.startsWith('http')
? `${window.location.origin}/oauth/callback/success?provider=${encodeURIComponent(provider)}`
: undefined;
const { authorizeUrl } = await getAuthorizeUrl(provider, { redirectUri });
openOAuthWindow(authorizeUrl);
} catch (error) {
@@ -178,7 +178,10 @@ export const useSkillConnect = ({ identifier, serverName, type }: UseSkillConnec
const provider = getLobehubSkillProviderById(identifier);
if (!provider) return;
const redirectUri = `${window.location.origin}/oauth/callback/success?provider=${encodeURIComponent(identifier)}`;
// Skip redirectUri on desktop (app:// protocol) since the system browser can't navigate to it
const redirectUri = window.location.protocol.startsWith('http')
? `${window.location.origin}/oauth/callback/success?provider=${encodeURIComponent(identifier)}`
: undefined;
const { authorizeUrl } = await getAuthorizeUrl(identifier, { redirectUri });
openOAuthWindow(authorizeUrl, identifier);
} catch (error) {
@@ -152,7 +152,10 @@ const LobehubSkillItem = memo<LobehubSkillItemProps>(({ provider, server }) => {
setIsConnecting(true);
try {
const redirectUri = `${window.location.origin}/oauth/callback/success?provider=${encodeURIComponent(provider.id)}`;
// Skip redirectUri on desktop (app:// protocol) since the system browser can't navigate to it
const redirectUri = window.location.protocol.startsWith('http')
? `${window.location.origin}/oauth/callback/success?provider=${encodeURIComponent(provider.id)}`
: undefined;
const { authorizeUrl } = await getAuthorizeUrl(provider.id, { redirectUri });
openOAuthWindow(authorizeUrl);
} catch (error) {