Authorization, how do i utilize cookie after i get it
Unanswered
Oak apple gall wasp posted this in #help-forum
Oak apple gall waspOP
export default function Login(){
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const initialValues: MyFormValues = {
email: '',
password: ''
}
const { mutate, data, isSuccess, isError, isPending } = useMutation({
mutationFn: async () => {
const authResponse = await axios.post('http://localhost:8080/auth/login', {
email, password
}).then((res) => res.data).catch((error) => console.log("heb error"))
return authResponse
}
})3 Replies
Oak apple gall waspOP
How do i use the cookie for authorization if i want to get or post more data to the server
you can read your cookie serverside and then confirm it with a method of your choice to check the auth from the user: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiesgetname
Oak apple gall waspOP
but my server is running on nestjs, the nestjs server are setting the cookie. I got the cookie, but I don't know how to attached it in every request to server after that...