Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(web,sentry): reduce noise from auth fetch errors and validate API URL

(justin)randoneeringf59194e3623c
diff --git a/apps/web/src/routes/auth.tsx b/apps/web/src/routes/auth.tsx
index 64c7bf2cb..5ae5c991b 100644
--- a/apps/web/src/routes/auth.tsx
+++ b/apps/web/src/routes/auth.tsx
@@ -1,4 +1,3 @@
-import * as Sentry from "@sentry/react";
import { createFileRoute, redirect } from "@tanstack/react-router";
import { authClient } from "@/lib/auth-client";
@@ -10,8 +9,7 @@ export const Route = createFileRoute("/auth")({
session = data;
} catch (error) {
if (import.meta.env.DEV) console.warn("getSession failed", error);
- Sentry.captureException(error, { tags: { area: "auth.getSession" } });
- // getSession() rejected — treat as unauthenticated, allow auth pages to render
+ // getSession() rejected (e.g. network error) — treat as unauthenticated, allow auth pages to render
}
if (session) {
throw redirect({
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index d19de9443..ae73800f9 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -11,6 +11,17 @@ const sentryAuthToken = process.env.SENTRY_AUTH_TOKEN;
const sentryOrg = process.env.SENTRY_ORG;
const sentryProject = process.env.SENTRY_PROJECT;
+// Validate that VITE_API_URL is explicitly set for production builds.
+// The auth client falls back to http://localhost:1337 when unset, which is
+// unreachable from a browser in production and causes "TypeError: Failed to fetch".
+if (process.env.NODE_ENV === "production" && !process.env.VITE_API_URL) {
+ throw new Error(
+ "[kaneo-web] VITE_API_URL must be set for production builds. " +
+ "Without it the auth client falls back to http://localhost:1337, " +
+ "which is unreachable from the browser and breaks authentication.",
+ );
+}
+
export default defineConfig({
define: {
__APP_VERSION__: JSON.stringify(packageJson.version),