且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在本地主机上运行多个express/Nodejs应用程序?

更新时间:2023-10-20 12:08:28

在端口3000上运行的应用程序的Cookie也会发送到在端口8080上运行的应用程序(反之亦然).

Cookies for an app running on port 3000 are also sent to an app running on port 8080 (and vice versa).

我的猜测是,您没有为每个应用提供唯一的 Cookie名称,因此这两个应用程序的会话处理之间可能会受到干扰.

My guess is that you didn't give each app a unique cookie name, so you might get interference between the session handling of both apps.

因此,请为每个名称使用不同的Cookie名称:

So, use a different cookie name for each:

app.use(session({
  name : 'frontend.sid', // and, say, 'admin.sid' for the admin app
  ...
}));