Repository pattern server side / How to use plugin custom fetch server side ?
Hello
I have a project with a custom fetch plugin allowing me to pass specific Bearers, and a split of the "API calls" part via the repository pattern.
As part of the development of a new general public site, we are thinking of making a BFF (backend for frontend) between the front and the API which is in PHP (but that doesn't matter)
The objective is to not let anything appear in the browser at the level of Bearers, endpoints, etc...
However I cannot use my implementations of the plugins and therefore what I did for the repository pattern.
Any ideas, how can i do it ?
Here is an illustration of what I want to do on the server/api/... side.
Here is an illustration of what I want to do on the server/api/... side.
![No description](https://cdn.answeroverflow.com/1263157001769189407/image.png)
4 Replies
Not sure If I understood your question correctly:
But You can define (as on your screenshot) Nitro Handler that will call you PHP API.
Browser -> Nitro -> PHP API.
So your repo with Bearers and endpoints will not be exposed on the client (Browser)
Browser will call you Nitro (Nuxt App) Endpoints.
Is this works for you?
That's what I'm trying to do.
The problem being that I have an authorization holder passed to each of my calls with a certain logic (done in a composable) and impossible to use it at the server level. I can't seem to find a way to make the equivalent of my plugin or composable usable on the server side
The capture is the plugin that I would like to use for each of my server-side calls
![No description](https://cdn.answeroverflow.com/1263394999119384596/image.png)
@Cesar look at the code of this repository i think you will find what you want
GitHub
GitHub - enkot/nuxt-open-fetch: Generate zero-overhead, typed OpenA...
Generate zero-overhead, typed OpenAPI clients for Nuxt. - enkot/nuxt-open-fetch