Hello, I am trying to implement a side-effect to t...
# support-questions-legacy
l
Hello, I am trying to implement a side-effect to the signInUp function from the backendConfig of a next.js app. What I am trying to accomplish is the creation of a profile row in a profile table when a user logs in with a new account. What I've done is grab the email from the input of the overridden method and sent it to an endpoint in my nest.js backend that then uses the email to get the user object and creates a profile with the non-sensitive information from that row(basically just the email and user_id). The issue I've encountered is that I want to secure the 'createProfile' endpoint in my nest.js backend with the supertokens SDK, but when I do I run into the problem of how I am supposed to get the accessToken cookie from the frontend and attach it to my request when it's a request that's made from inside of the overrride of the signInSignUp function in the backendConfig of our next.js app. I am not sure if I am barking up the wrong tree trying to implement this like this, or if I am just missing something. Feedback would be appreciated :).
r
hey @Lindo (Hannes Colt)
So this is the backend (nextjs API) calling another backend (nestJS API) correct?
l
Exactly!
r
Okay! Just give me 5-10 mins and I can send a writeup.
l
Thank you very much, I gotta run and grab some lunch, will be back in at most 20, didn't think you would be so fast in answering! 🙂
r
haha fair.. i'll send a short writeup anyway
Right, so for backend to backend communication, you want to get the session handle from the session (which you can get from the response of
originalImplementation.signInUpPOST()
). Pass this session handle to the nestJS server which can use it to get info about the session (and hence the userId associated with that session). The access and refresh tokens are mainly meant for frontend to backend communication, and not backend to backend.
l
Thank you for the answer! 😄
3 Views