Hellno009
Hellno009
HHono
Created by Hellno009 on 8/9/2024 in #help
Hono client issues with newrelic?
Guys, I almost gave up.. I cant solve the issue: - I added newrelic for monitoring - All my endpoints goes to 401 Unauthorized I started to debug and im using hono with react query: So basically this one not works If I start my app with newrelic: import { client } from "@/lib/hono"; import { useQuery } from "@tanstack/react-query"; import { TrackedTimeResponse } from "@/features/statistics/types"; export const useGetTrackedTime = () => { return useQuery<TrackedTimeResponse, Error>({ queryKey: ["get-tracked-time"], queryFn: async () => { try { const response = await client.api.statistics["get-tracked-time"].$get(); if (!response.ok) { throw new Error(API Error: ${response.status} ${response.statusText}); } const data = await response.json();
return data; } catch (error) { console.error("Error in useGetTrackedTime:", error); throw error; } }, }); }; But.. If I remove hono client and just make simple fetch (or even If I try this endpoint on my browser): export const useGetTrackedTime = () => { return useQuery<TrackedTimeResponse, Error>({ queryKey: ["get-tracked-time"], queryFn: async () => { try { const response = await fetch('/api/statistics/get-tracked-time'); if (!response.ok) { throw new Error('Failed to fetch data'); } return response.json(); } catch (error) { throw error; } }, }); }; It works and returns 200. Any have anything similar? Any recommendations?
4 replies