What to refactor?
This project has several areas that could be improved, but the frontend fetching layer is one of the most problematic parts.
Main issues:
-
Two separate clients: useApi and useAuth
Why are we maintaining two separate clients? This duplicates types, OpenAPI generation, and client logic without a clear benefit. A single client with a parameter or configuration option would likely be simpler and easier to maintain.
-
Plugin-based customization
Using a Nuxt plugin to customize fetching is no longer the recommended approach. Nuxt now supports better patterns, such as fetch hooks or a custom composable based on the official custom useFetch recipe:
https://nuxt.com/docs/4.x/guide/recipes/custom-usefetch
-
Unnecessary auth refresh spam
This is related to the auth redesign, but we should avoid constantly triggering refresh requests. We can immediately detect when the auth token is missing, and we can also parse the JWT client-side to check whether it has expired before attempting a refresh.
Overall, I think this part should be simplified significantly. We should move toward a single typed fetch client, avoid plugin-based fetch customization, and make the auth refresh logic less noisy and more predictable.
What to refactor?
This project has several areas that could be improved, but the frontend fetching layer is one of the most problematic parts.
Main issues:
Two separate clients:
useApianduseAuthWhy are we maintaining two separate clients? This duplicates types, OpenAPI generation, and client logic without a clear benefit. A single client with a parameter or configuration option would likely be simpler and easier to maintain.
Plugin-based customization
Using a Nuxt plugin to customize fetching is no longer the recommended approach. Nuxt now supports better patterns, such as fetch hooks or a custom composable based on the official
custom useFetchrecipe:https://nuxt.com/docs/4.x/guide/recipes/custom-usefetch
Unnecessary auth refresh spam
This is related to the auth redesign, but we should avoid constantly triggering refresh requests. We can immediately detect when the auth token is missing, and we can also parse the JWT client-side to check whether it has expired before attempting a refresh.
Overall, I think this part should be simplified significantly. We should move toward a single typed fetch client, avoid plugin-based fetch customization, and make the auth refresh logic less noisy and more predictable.