#NestJs Auth always returns 401 Unauthorized using browser after implementing local strategy

5 messages · Page 1 of 1 (latest)

thin stump
#

Hi, I recently implemented authentication in my Nest app and I used the local strategy for this. It's possible to sign in using email + password with Postman, and get a cookie back, but when I try the exact same thing in my browser it instantly returns a 401 Unauthorized. I had a issue earlier with CORS but I fixed that, now it's just this issue I am encountering. Any way to debug this?

celest slate
#

show us the request payload
and the controller method responsible for handling that route

thin stump
#

thanks for the response, but i found the issue, but I cant exactly say i understand it

#
import axios from 'axios';

const api = axios.create({
    baseURL: 'http://localhost:3000/api', //your api URL
    withCredentials: true,
    headers: {
        'Content-type': 'application/json'
    }
});

export default api;

removing the headers here solves the issue

#

but now it doesnt set the cookies in the browser. so tired