I'm currently working on an application built on microservices that looks roughly like this :
Client
|
Gateway (express)
________|_________
| | |
Express Express Other
Service Service Service
I would like to share a session between the gateway and all the services using redis as a session storage.
I tried using express-session
and connect-redis
and configure it like this on every service :
app.use(
session({
store: new redisStore({
host: "redis",
port: 6379,
prefix: "sess",
db: 4,
}),
name: "shared_session",
secret: "mysecret",
saveUninitialized: false,
resave: false,
}),
);
But when I try to set a variable in a service, I can't retrieve it in the other services as the session object seems different each time.
How to correctly configure express-session
and connect-redis
to share a session between my services and how to retrieve the correct session ?
via C. Gelnä
No comments:
Post a Comment