Search code examples
meteorreverse-proxymeteor-accounts

Share Meteor accounts between apps with same DB behind reverse proxy


I don't know enough about how Meteor manages sessions and accounts to know if I have more than one app connected to the same MongoDB behind a reverse proxy will work seamlessly when people are logged in.

The idea is that I split functions into separate apps, and yet they can move around the website normally.

So they start using one app at root (/), then move to the helpdesk (/help), which is served by another app connected to the same DB. They logged in on '/', and so will they still be logged in on '/help'?


Solution

  • I tried it, and it can work.

    I use Nginx and there are a few things to notice (but wasn't part of question so won't put here).

    But the key for Meteor is what I found in a comment somewhere: in each app in a subdirectory run localStorage["Meteor.loginToken"] && Accounts.loginWithToken(localStorage["Meteor.loginToken"]). Also use the ROOT_URL environment variable correctly when starting apps in subdirectories.