RR7 + Cloudflare

I have a simple hello world app created using RR7 and CF worker. I am trying to invoke a api endpoint ( hono ) from the loader function of react component. The app works fine when I run in local environment. But when I deploy to CF worker, the API endpoint invocation fails with error 404. Can someone please help me debug the issue. The code can be found here : https://github.com/bikash119/getting-started-v3
GitHub
GitHub - bikash119/getting-started-v3
Contribute to bikash119/getting-started-v3 development by creating an account on GitHub.
2 Replies
Kenny
Kenny7mo ago
I had trouble with this as well (w/o using hono and calling internal apis from loaders) and the only way I was able to get it to work was by importing the actual loader function from the other file, casting it to a name like userLoader and then calling that in the loader directly. Not really helpful in your specific case but just thought i'd mention it.
bikash
bikashOP7mo ago
Thanks Kenny for your reply. I could get past the issue. My understanding of loader function was not very clear. Once I understood how the loader function works, I was able to make it work and understand the behaviour. What I know now is : The loader function can be thought of as a backend api. Now if you think it, if you have 2 backend function, you won't invoke one from another through a rest end point call. You would directly invoke it. The same is true for loader function. In my case, I was trying to invoke supabase api calls from loader function through hono api endpoint. But since loader function is already a backend function, we can directly invoke supabase api calls without routing our call through hono api. Hope I am making sense. Please let me know if you think otherwise.

Did you find this page helpful?