this is my server component using server actions
const result = await LoginSchema.isValid(await data)
if (result === true) {
try {
const dota_resp = await pb.collection('UserTable').authWithPassword(await data.Email, await data.Password);
if (dota_resp && await pb.collection('UserTable').authRefresh()) {
cookies().set(pb.authStore.exportToCookie({httpOnly: true}), { secure: false })
return {"success": JSON.stringify(pb.authStore)}
}
else{
return{"failed": "something went wrong with with validation"}
}
}
catch (error) {
return { "failed": JSON.stringify(error) };
}
}
and i just manually setting authstore
if (dependency.success) {
setIsPending(false)
const DataMutation = JSON.parse(dependency.success)
const tok = await DataMutation.storageFallback.pocketbase_auth.token
const mod = await DataMutation.storageFallback.pocketbase_auth.model
pb.authStore.save(tok,mod)
return router.push("/")
}
im trying to access cookie from middleware
if (request.nextUrl.pathname.startsWith('/account')) {
console.log(response.headers)
if(await request.cookies.has("pb_auth")){
return NextResponse.next()
}
else{
return NextResponse.redirect(new URL('/', request.url))
}
}
im only beginner, but i think im missing something...
i tried to debug for whole day...but no result...i hope somebody could help me.