Next.js Discord

Discord Forum

Request from repository Pattern

Unanswered
ZenRu posted this in #help-forum
Open in Discord
Hello everyone,

I've created a repository class to make my API calls from the getServerSideProps method.
I would like to pass only the authentication token to my method (e.g. get(token)).
However, I'd also like to retrieve the current request from my repository without passing it as an argument or going through the middleware.

Does this seem possible to you?

2 Replies

I don't have any answers yet, but I've found two interesting leads that I'm going to try out and give feedback on for those who are in the same situation as me.

- https://stackoverflow.com/questions/75815512/get-request-url-in-nextjs-server-component-inside-the-app-folder
- Using Context
- For the first bullet point it does not work on Next 13.2
- The second one is ok for the CSR part but not for the SSR

Unfortunately, I think I'm going to have to pass on the request and therefore a lot of information in order to be able to manage both part.