N
Nuxt6mo ago
Cesar

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.
No description
4 Replies
Frox
Frox6mo ago
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?
Cesar
CesarOP6mo ago
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
xibman
xibman6mo ago
@Cesar look at the code of this repository i think you will find what you want
xibman
xibman6mo ago
GitHub
GitHub - enkot/nuxt-open-fetch: Generate zero-overhead, typed OpenA...
Generate zero-overhead, typed OpenAPI clients for Nuxt. - enkot/nuxt-open-fetch
Want results from more Discord servers?
Add your server