Hi again, I'm using the client `toSession` method ...
# ory-network
l
Hi again, I'm using the client
toSession
method on the backend server (Node.js/Nest.js), and passing in the cookie sent from the client. This works fine on my self-hosted ory kratos instance, where the cookie name is
ory_kratos_session
, but after signing in via the Ory Network in production, the cookie name is
ory_session_[MY_API_ENDPOINT]
which doesn't seem to be picked up by the ory client as it returns a 401
Copy code
const session: Session | null = await this.ory
  .toSession(undefined, request.headers['cookie'])
  .then((result: AxiosResponse<Session>) => {
    request.userId = result.data.identity.id;
    return result.data;
  })
  .catch((e) => {
    if (e.response.status === 401) {
      throw new HttpException({
        status: HttpStatus.UNAUTHORIZED,
        error: 'error.sessionNotFound'
      }, HttpStatus.UNAUTHORIZED);
    }
    console.error('Error Getting Session', e.response.status);
    return null;
  });
The server side session check
I exported the Ory Network project settings to check the session cookie name and it seems to match
Wondering now if my reverse proxy (Traefik) is in fact removing the cookie
Hmm nope, the session cookie is reaching the server properly