fix: remove /api/ double-prefix from all frontend API calls
Frontend api.ts baseUrl is already "/api", so paths like "/api/cases" produced "/api/api/cases". Stripped the redundant prefix from all component calls. Rewrite destination correctly adds /api/ back for the Go backend.
This commit is contained in:
@@ -41,7 +41,7 @@ export function AppointmentModal({ open, onClose, appointment }: AppointmentModa
|
||||
|
||||
const { data: cases } = useQuery({
|
||||
queryKey: ["cases"],
|
||||
queryFn: () => api.get<{ cases: Case[]; total: number }>("/api/cases"),
|
||||
queryFn: () => api.get<{ cases: Case[]; total: number }>("/cases"),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -66,7 +66,7 @@ export function AppointmentModal({ open, onClose, appointment }: AppointmentModa
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (body: Record<string, unknown>) =>
|
||||
api.post<Appointment>("/api/appointments", body),
|
||||
api.post<Appointment>("/appointments", body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["appointments"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["dashboard"] });
|
||||
@@ -89,7 +89,7 @@ export function AppointmentModal({ open, onClose, appointment }: AppointmentModa
|
||||
});
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: () => api.delete(`/api/appointments/${appointment!.id}`),
|
||||
mutationFn: () => api.delete(`/appointments/${appointment!.id}`),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["appointments"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["dashboard"] });
|
||||
|
||||
Reference in New Issue
Block a user