Protected API Routes in with-firebase-authentication example #13222
Unanswered
vijaynandwani
asked this question in
Help
Replies: 1 comment
-
I realized that idToken expire in one hour. And the cookie doesn't have the updated Token. I removed verifyIdToken check, extracted values from cookie using jwt-decode, added the values to req, and proceeded to API route. In my API I am checking if user_id has access to perform the action or not |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Dear next.js community,
Thank you for such a nice project and an active community. I am new to Next.Js and have been trying to understand how does Firebase Authentication example works.
My project requires me to have an API because some non-Nextjs part of the website needs to make request to the API. So I cannot use getServerSideProps for that part and need to make a protected API route.
My solution was to use the cookie that the example stores in the browser and use the cookie data to authenticate users. Here is my implementation. Am I doing this the right way?
/utils/middleware/protectedApi.js
and here is the API route
/pages/api/test.js
Please let me know if there is a better way to do this.
Thank you once again!
Regards
Vijay
Beta Was this translation helpful? Give feedback.
All reactions