Open p45mark opened 3 years ago
With API calls, the easiest and safest thing to do is generate an ID token (either grab it from the cookie client-side or generate a new one with firebaseClient.currentUser?.getIdToken()
and send it as part of your request (either as a header or in the body of the request somewhere). Then validate it in the route logic with verifyIdToken
like you described. This is safer than using cookies for CSRF reasons.
@colinhacks this was my question as well. is there any chance u can add a /api/ route to ur repo ?
I'm wondering if we have to take the code from here - https://github.com/vercel/next.js/tree/canary/examples/api-routes-apollo-server-and-client-auth
Thanks a lot for sharing this approach! I'm curious if you have any suggestions as to how I can secure an API route? I tried to just verify that the token exists and is valid, but calling this in my API returns the error that the token expired
From my secure page
my API. This throws the error