Hono client issues with newrelic?
Guys, I almost gave up.. I cant solve the issue:
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(
}
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?
- I added newrelic for monitoring
- All my endpoints goes to 401 Unauthorized
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?