-
Notifications
You must be signed in to change notification settings - Fork 0
solved potential issue #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +0,0 @@ | ||
| VITE_API_URL='https://subly-backend-iuej.onrender.com' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import * as React from "react" | ||
| import { Slot } from "radix-ui" | ||
|
|
||
| import { cn } from "@/lib/utils" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| import * as React from "react" | ||
|
|
||
| import { cn } from "@/lib/utils" | ||
|
|
||
| function Card({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| import * as React from "react" | ||
|
|
||
| import { cn } from "@/lib/utils" | ||
|
|
||
| function Input({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| import * as React from "react" | ||
|
|
||
| import { cn } from "@/lib/utils" | ||
|
|
||
| function Table({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,10 @@ export function cn(...inputs) { | |
| return twMerge(clsx(...inputs)); | ||
| } | ||
|
|
||
| export function getApiBaseUrl() { | ||
| return import.meta.env.VITE_API_URL || "http://localhost:3000"; | ||
| } | ||
|
|
||
|
Comment on lines
+9
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Align fallback API port with server default to avoid local breakage. Line 10 defaults to 🔧 Proposed fix export function getApiBaseUrl() {
- return import.meta.env.VITE_API_URL || "http://localhost:3000";
+ return import.meta.env.VITE_API_URL || "http://localhost:3001";
}Also applies to: 148-148 🤖 Prompt for AI Agents |
||
| export function formatMoney(amountInMinorUnit, currency) { | ||
| return new Intl.NumberFormat("en-NG", { | ||
| style: "currency", | ||
|
|
@@ -141,7 +145,7 @@ async function extractErrorMessage(response) { | |
| let refreshPromise = null; | ||
|
|
||
| export async function fetchWithAuth(url, options = {}) { | ||
| const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:3000"; | ||
| const API_BASE_URL = getApiBaseUrl(); | ||
| try { | ||
| let response = await fetch(`${API_BASE_URL}${url}`, { | ||
| ...options, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { Link } from "react-router"; | ||
| import { SearchX } from "lucide-react"; | ||
|
|
||
| import { Button } from "@/components/ui/button"; | ||
|
|
||
| export default function NotFound() { | ||
| return ( | ||
| <main className="flex min-h-screen items-center justify-center bg-subly-background px-4"> | ||
| <div className="w-full max-w-md rounded-xl border border-subly-border bg-subly-card p-8 text-center shadow-sm"> | ||
| <div className="mx-auto flex h-14 w-14 items-center justify-center rounded-xl bg-subly-soft-blue text-subly-brand-blue"> | ||
| <SearchX size={26} /> | ||
| </div> | ||
| <h1 className="mt-5 text-3xl font-bold text-subly-text-primary">404</h1> | ||
| <p className="mt-2 text-sm text-subly-text-secondary"> | ||
| The page you are looking for does not exist. | ||
| </p> | ||
| <Button asChild className="mt-6"> | ||
| <Link to="/dashboard">Go to dashboard</Link> | ||
| </Button> | ||
| </div> | ||
| </main> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Stop redirecting to
/auth/loginfor non-auth failures.At Line 12, every caught error redirects to login. Since
fetchWithAuththrows on any non-OK status, transient backend failures (e.g./api/me5xx) are treated as auth failures and force incorrect redirects.💡 Suggested fix
export async function dashboardLoader() { try { const response = await fetchWithAuth("/api/me"); return await response.json(); } catch (err) { console.error("Error fetching user data:", err); - return redirect("/auth/login"); + if (err?.status === 401 || err?.status === 403) { + return redirect("/auth/login"); + } + throw err; } }Also make sure
fetchWithAuthattachesstatusto thrown errors so this branch is reliable.🤖 Prompt for AI Agents