You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got cookie based auth but I cannot make it work on my NextJS Project in server components.
Working examples:
Working example in server component
constgetData2=async()=>{try{constresponse=awaitfetch(newURL(SAME_URL_AS_IN_LOGOUT_SERVICE),{headers: {Cookie: cookies().toString()},})returnresponse.json()}catch(err){console.log(err)// console.log("error", err)}}......
.....Server component:
constdata=awaitgetData()// auth works here
Working example in client component, looks like cookies are correctly passed here.
useclientReact.useEffect(()=>{constgetData=async()=>{constgetDataNotWorkingAuth=async()=>{try{returnawaitLogoutService.isAuthorizedUsingGet();}catch(err){console.log(err);}}constdata=awaitgetDataNotWorkingAuth();// Auth works here}getData();},[]);
Not working example in server component:
OpenAPI.HEADERS={Cookie: cookies().toString()}constgetDataNotWorkingAuth=async()=>{try{returnawaitLogoutService.isAuthorizedUsingGet()}catch(err){console.log(err)// console.log("error", err)}}...
...
Server component:
constdata=getDataNotWorkingAuth()//not authenticated
Do you have any idea how to make it work with typescript codegen?
The text was updated successfully, but these errors were encountered:
I've got cookie based auth but I cannot make it work on my NextJS Project in server components.
Working examples:
Not working example in server component:
Do you have any idea how to make it work with typescript codegen?
The text was updated successfully, but these errors were encountered: