I tried to create login in my app like this:
export const Login = async ({ name, email, password }: Credentials) => {
console.log('Creating user with:', name, email, password)
try {
const response = await fetch('http://localhost:3000/api/users/login', {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
// name,
email,
password,
}),
})
const data = await response.json()
console.log('response ===>>>', data)
if (response.ok) {
console.log('Yes-----------------------------------')
} else {
console.log('NO user(((')
}
} catch (error) {
console.log(error)
}
}
and it kinda passes the auth.. but it does not send any cookie and basically does not login in a way logging with normal payload login form does..
Also, even more interesting question. How can I implement creating a user on my app, e.g. registering?