From 84102a94539789d9f1b37ff5e4cbee5d2500b122 Mon Sep 17 00:00:00 2001 From: rxmox Date: Fri, 1 May 2026 23:18:30 -0600 Subject: [PATCH] Restore LinkedIn login on web build The shared loginWithLinkedIn helper hardcoded ?platform=mobile and used WebBrowser.openAuthSessionAsync with a custom-scheme redirect, which broke the Expo web export at https://shatter-mobile.vercel.app/. After LinkedIn auth completed, the backend redirected the browser to shattermobile://auth/auth/callback?code=..., a custom scheme browsers cannot follow. Branch on Platform.OS: on web, navigate the current tab directly to the backend's /api/auth/linkedin (no platform param). The backend defaults to the web flow and redirects to ${FRONTEND_URL}/auth/callback?code=..., which the existing app/auth/callback.tsx route handles. The mobile path is unchanged. --- shatter-mobile/src/services/linkedin_auth.service.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shatter-mobile/src/services/linkedin_auth.service.ts b/shatter-mobile/src/services/linkedin_auth.service.ts index 1bb6891..c9aaf94 100644 --- a/shatter-mobile/src/services/linkedin_auth.service.ts +++ b/shatter-mobile/src/services/linkedin_auth.service.ts @@ -1,5 +1,6 @@ import * as Linking from "expo-linking"; import * as WebBrowser from "expo-web-browser"; +import { Platform } from "react-native"; import { User } from "../interfaces/User"; import { exchangeLinkedInCode, userFetch } from "./user.service"; @@ -8,6 +9,11 @@ const REDIRECT_SCHEME = "shattermobile://auth"; export async function loginWithLinkedIn(): Promise< { user: User; token: string } | null > { + if (Platform.OS === "web") { + window.location.href = `${process.env.EXPO_PUBLIC_API_BASE}/api/auth/linkedin`; + return null; + } + const result = await WebBrowser.openAuthSessionAsync( `${process.env.EXPO_PUBLIC_API_BASE}/api/auth/linkedin?platform=mobile`, REDIRECT_SCHEME,