Something really curious about your code is that if you build it and run the build
it works properly, but if you try to run it using npm run dev
it doesn't. I am trying to debug your code to make sure I can implement the same behavior but using route handler.