Skip to content

[Refactor]: Refactor frontend fetching implementation #873

@Norbiros

Description

@Norbiros

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:

  1. 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.

  2. 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

  3. 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.

Metadata

Metadata

Assignees

No fields configured for Refactor.

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions