IamIconLiving
IamIconLiving9mo ago

I have an actual data returned, but I get 404 spammed in the console

It's a bit weird, I have the data returned but I also get 404 at the same time. Here is usage on the frontend:
const { data, error } = api.profile.get.useQuery();
console.log("profile get error", error);
console.log("profile data", data);
const { data, error } = api.profile.get.useQuery();
console.log("profile get error", error);
console.log("profile data", data);
And here is the route:
export const profileRouter = createTRPCRouter({
get: privateProcedure.query(({ ctx }) => {
const profile = ctx.db.profiles.findFirst({
where: {
id: ctx.user.id,
},
});
return profile;
}),
export const profileRouter = createTRPCRouter({
get: privateProcedure.query(({ ctx }) => {
const profile = ctx.db.profiles.findFirst({
where: {
id: ctx.user.id,
},
});
return profile;
}),
What can I do to fix it?
No description
4 Replies
IamIconLiving
IamIconLivingOP9mo ago
This is what I get in the console log spammed
No description
IamIconLiving
IamIconLivingOP9mo ago
But data is returned from the trpc route..
IamIconLiving
IamIconLivingOP9mo ago
it actually seems to be related to this issue https://github.com/trpc/trpc/issues/3081 In my codebase I was using unstable_httpBatchStreamLink and once I switched it to httpBatchLink I got the same error as described in 3081 issue
GitHub
httpLink/httpBatchLink on fetch redirect · Issue #3081 · trpc/trpc
Provide environment information System: OS: macOS 11.6.8 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 610.94 MB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 18.11.0 - ~/.nvm/v...
IamIconLiving
IamIconLivingOP9mo ago
but as it's closed I am not exactly sure what I need to do to fix it Actually this is related to the fact that my entire app is under dynamic [lang] directory for the internalization, so my app url is foo.com/en If I move my up on the level up it works fine. How can I ensure this is not breaking with internalization? ... placed the api folder under my [lang directory, which caused the problem