Link navigation not triggering middleware
Unanswered
Pteromalid wasp posted this in #help-forum
Pteromalid waspOP
i log in, set the cookie, click on a Link to my middleware protected /admin page and nothing happens. if i refresh/go to that page from the url then it works
i've tried link and a href
what do i need to do to fix this...
i've tried link and a href
export function Navbar() {
const router = useRouter();
const sessionData = useAtomValue(sessionDataAtom)
console.log("[Navbar] sessionDataAtom value:", sessionData);
const AdminLink = () => {
const handleClick = (e) => {
e.preventDefault();
router.refresh();
router.push('/admin');
};
return (
<a href="/admin" onClick={handleClick}>
Admin
</a>
);
};
return (
<>
<div className='w-full flex flex-row items-center justify-between p-4'>
<div className='flex flex-row gap-4 items-center'>
<Link href="/">
home
</Link>
{/* <Link href="/admin">
Admin
</Link> */}
{/* <Link as="/admin" href="/admin">
Admin
</Link> */}
<AdminLink />
<span>{sessionData?.telegram_username}</span>
</div>
</div>
</>
)
}
what do i need to do to fix this...