I have not too much experience with Angular and generally web development so this topic is a little bit problematic for me. I am trying to get a session from kratos to authorize an user but I still get some errors. There is my code:
this.kratos
.toSession(undefined, 'Cookie')
.then(({ data: session }) => {
// `whoami` returns the session or an error. We're changing the type here
// because express-session is not detected by TypeScript automatically.
console.log('SESSION: ' + session);
})
.catch(() => {
// If no session is found, redirect to login.
console.log('REDIRECTED');
});
There are errors which I am getting:
Uncaught TypeError: Cannot read property 'addEventListener' of null
Angular is running in development mode. Call enableProdMode() to enable production mode.
Refused to set unsafe header "Cookie"
http://…3/sessions/whoamiFailed to load resource: the server responded with a status of 401
(Unauthorized)
REDIRECTED
There are cookies in my browser:
ory_kratos_session MTYyNjE5MjkwNHxEdi(...) 127.0.0.1
TawkConnectionTime 0 127.0.0.1
csrf_token iappKdv+/YcnaJGEPop(...) 127.0.0.1
I use the newest version of Ory Kratos and Angular. The browser is chrome with installed allow CORS addon.