#NextAuth with Spring Backend

13 messages · Page 1 of 1 (latest)

urban sparrowBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

jade roost
jade roost
#

yeah it is, some kind of reverse proxy like that is most easiest way to query your backend without configuring cors and messing with cookie policies.

hollow bison
#

you can do bearer token instead

#

and just send it every request, thats what we do

#

just jwt token, if it expires or 401s just redirect to login

#

what we have in the backend are api, we just made a frontend out of it, the same api used by mobile app

jade roost
#

then you need to query your backend at server side of nextjs, where you prehydrate your ssr, and do actions based on data you have, and still rewrite is better because you'll have access to your auth cookies directly inside nextjs

hollow bison
#

in the middleware add the Authorization Bearer header with the token

#

the middleware must send this every request

#

we didnt use cookies, we just used local storage

#

wait its local storage i think

jade roost
#

you check them not on frontend, on backend, and prehydrate page accordignly, yeah having access to cookies is not a lot benefit, it only will allow to reject request if cookies are not presented, if they are presented you still need to query your java backend to verify session, and only after that prehydrate page for user.