When the frontend (A) is hitting the backend for /login
, The backend ExpressJs (B) responds with a httpOnly
cookie by doing:
ctx.res.cookie('auth-token', jwt.sign({ userId: userId }, APP_SECRET, { expiresIn: 100000 }), {
httpOnly: true,
maxAge: 100000,
})
The frontend (A) save this cookie (as httpOnly) and forward this cookie to the backend (B) for the next call (example /getMe
). The backend (B) has access to this cookie with cookie.parse(ctx.req.headers.cookie)
It works well.
Now another backend (expressJs) (C) needs to login to the Backend (B) with an axios
request for example. (C) will hit (B) via /login
. A httpCookie is in the header of this call. It works well. But (C) cannot save the cookie as httpOnly and then cannot forward to (B) this cookie for the next call.
How (C) can forward the httpOnly cookie to (B) for doing an authenticated call like /getMe
?