Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix: Route auth flows through API proxy for Electron compatibility with Neon Auth
Gabriel Steinf5488bdd3934
diff --git a/main.js b/main.jsindex 659ca1294..5b27e478e 100644--- a/main.js+++ b/main.js@@ -405,11 +405,8 @@ async function startApp() {initializeManagers();startAuthBridgeServer();- // Inject Origin header for Neon Auth requests.- // Electron loads pages from file:// so the browser sends no Origin header,- // which Neon Auth (better-auth) rejects. This is the standard Electron- // approach: use webRequest.onBeforeSendHeaders at the Chromium network layer.- // Match all Neon Auth endpoints (avoids dependency on .env which isn't packaged).+ // Electron's file:// sends no Origin header, which Neon Auth rejects.+ // Inject the request's own origin at the Chromium network layer.session.defaultSession.webRequest.onBeforeSendHeaders({ urls: ["https://*.neon.tech/*"] },(details, callback) => {diff --git a/src/components/AuthenticationStep.tsx b/src/components/AuthenticationStep.tsxindex 172f89937..b4cf0745e 100644--- a/src/components/AuthenticationStep.tsx+++ b/src/components/AuthenticationStep.tsx@@ -105,6 +105,17 @@ export default function AuthenticationStep({useEffect(() => {if (isLoaded && isSignedIn) {+ if (OPENWHISPR_API_URL && user?.id && user?.email) {+ fetch(`${OPENWHISPR_API_URL}/api/auth/init-user`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ userId: user.id,+ email: user.email,+ name: user.name || null,+ }),+ }).catch((err) => console.error("Failed to init user:", err));+ }onAuthComplete();}}, [isLoaded, isSignedIn, onAuthComplete]);@@ -210,6 +221,23 @@ export default function AuthenticationStep({}} else {updateLastSignInTime();++ if (OPENWHISPR_API_URL) {+ try {+ await fetch(`${OPENWHISPR_API_URL}/api/auth/init-user`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ userId: result.data?.user?.id,+ email: email.trim(),+ name: fullName.trim() || email.trim().split("@")[0],+ }),+ });+ } catch (initErr) {+ console.error("Failed to init user:", initErr);+ }+ }+onNeedsVerification(email.trim());}} else {diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex d3267c027..6464e9ea1 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -853,7 +853,11 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPageonClick={async () => {const result = await usage.openBillingPortal();if (!result.success) {- toast({ title: "Couldn't open billing", description: result.error, variant: "destructive" });+ toast({+ title: "Couldn't open billing",+ description: result.error,+ variant: "destructive",+ });}}}variant="outline"@@ -867,7 +871,11 @@ export default function SettingsPage({ activeSection = "general" }: SettingsPageonClick={async () => {const result = await usage.openCheckout();if (!result.success) {- toast({ title: "Couldn't open checkout", description: result.error, variant: "destructive" });+ toast({+ title: "Couldn't open checkout",+ description: result.error,+ variant: "destructive",+ });}}}size="sm"diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.jsindex dd463274e..8576b958f 100644--- a/src/helpers/audioManager.js+++ b/src/helpers/audioManager.js@@ -1631,7 +1631,11 @@ class AudioManager {logger.debug("AudioWorklet module pre-loaded during warmup", {}, "streaming");}} catch (e) {- logger.debug("AudioWorklet pre-load failed (will retry on recording)", { error: e.message }, "streaming");+ logger.debug(+ "AudioWorklet pre-load failed (will retry on recording)",+ { error: e.message },+ "streaming"+ );}// Warm up the OS audio driver by briefly acquiring the mic, then releasing.@@ -1645,7 +1649,11 @@ class AudioManager {this.micDriverWarmedUp = true;logger.debug("Microphone driver pre-warmed", {}, "streaming");} catch (e) {- logger.debug("Mic driver warmup failed (non-critical)", { error: e.message }, "streaming");+ logger.debug(+ "Mic driver warmup failed (non-critical)",+ { error: e.message },+ "streaming"+ );}}diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 425ec16a8..a43b41305 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -1535,12 +1535,20 @@ class IPCHandlers {// Clean up any stale active connection (shouldn't happen normally)if (this.assemblyAiStreaming.isConnected) {- debugLogger.debug("AssemblyAI cleaning up stale connection before start", {}, "streaming");+ debugLogger.debug(+ "AssemblyAI cleaning up stale connection before start",+ {},+ "streaming"+ );await this.assemblyAiStreaming.disconnect(false);}const hasWarm = this.assemblyAiStreaming.hasWarmConnection();- debugLogger.debug("AssemblyAI streaming start", { hasWarmConnection: hasWarm }, "streaming");+ debugLogger.debug(+ "AssemblyAI streaming start",+ { hasWarmConnection: hasWarm },+ "streaming"+ );let token = this.assemblyAiStreaming.getCachedToken();if (!token) {diff --git a/src/lib/neonAuth.ts b/src/lib/neonAuth.tsindex 009247c12..1290412ec 100644--- a/src/lib/neonAuth.ts+++ b/src/lib/neonAuth.ts@@ -1,5 +1,6 @@import { createAuthClient } from "@neondatabase/auth";import { BetterAuthReactAdapter } from "@neondatabase/auth/react";+import { OPENWHISPR_API_URL } from "../config/constants";export const NEON_AUTH_URL = import.meta.env.VITE_NEON_AUTH_URL || "";export const authClient = NEON_AUTH_URL@@ -200,11 +201,11 @@ export async function signInWithSocial(provider: SocialProvider): Promise<{ erro}try {- // Build an absolute callback URL. Neon Auth redirects here after OAuth.- // In the browser, this page detects it's outside Electron and redirects- // to the app's custom protocol to hand the verifier back to Electron.- const base = window.location.href.split("?")[0].split("#")[0];- const callbackURL = `${base}?panel=true`;+ // Electron's file:// origin is rejected by Neon Auth — use a relative path instead+ const isElectron = Boolean((window as any).electronAPI);+ const callbackURL = isElectron+ ? "/?panel=true"+ : `${window.location.href.split("?")[0].split("#")[0]}?panel=true`;await authClient.signIn.social({provider,@@ -219,8 +220,8 @@ export async function signInWithSocial(provider: SocialProvider): Promise<{ erro}/**- * Requests a password reset email to be sent to the specified email address.- * The email contains a link that redirects to the app with a reset token.+ * Requests a password reset email. Routes through the API proxy when available,+ * falls back to direct Neon Auth for web environments.*/export async function requestPasswordReset(email: string): Promise<{ error?: Error }> {if (!authClient) {@@ -228,8 +229,22 @@ export async function requestPasswordReset(email: string): Promise<{ error?: Err}try {- // Build the redirect URL for the password reset link.- // This will redirect back to the app with a token parameter.+ if (OPENWHISPR_API_URL) {+ const res = await fetch(`${OPENWHISPR_API_URL}/api/auth/forgot-password`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ email: email.trim() }),+ });++ if (!res.ok) {+ const data = await res.json().catch(() => ({}));+ throw new Error(data.error || "Failed to send reset email");+ }++ return {};+ }++ // Fallback: direct Neon Auth (web environments with proper URLs)const base = window.location.href.split("?")[0].split("#")[0];const redirectTo = `${base}?panel=true&reset_password=true`;