Data privacy and switching servers

We are being forced to have servers in France due to privacy laws, so local mongoDB, meteor server etc.

How can the client switch servers on the fly? We tried all different combinations of Meteor.connect and DDP.connect and we still can’t log in to another server.

No one? Am I the only one facing this? @sashko, some direction would be appreciated if you have a moment.
I would expect international sites to want to direct to local servers to reduce latency and distribute load.

I noticed that Meteor.subscribe (and other functions) simply point to the current connection’s subscribe method. Should we just replace these functions manually or use the cumbersome approach of calling subscribe of a new DDP.connect() response?

What do you mean by “switch servers on the fly”?

Connect to another container running the same exact App elsewhere. E.g. we deploy in US and Europe. When a user connects, we notice they are in Europe and have the App point to the European site.

Why not just connect to the same server every time? When people load the app in Europe, they can just be redirected to the european server to start with. I don’t see any reason to switch server URLs while the app client is already running in this case.

So a normal web url redirect? My concern was about user experience but I guess that’s the only option.

I think one redirect when the app starts isn’t a big deal, especially if you can do it server-side without loading the whole app. Many applications do a redirect to a different domain based on various factors.

What do you mean server-side? Thanks

You can use middlewares on Meteor’s web server, WebApp, which is based on connect:

This way, you can do redirects server-side, without waiting for JavaScript to load on the client. See here for example:

1 Like

Understood, so you would suggest that the root of the app (i.e. /) is handled by webapp connect handler?
Which then redirects as need be.

My understanding is that you can’t have both flowrouter and webapp listen to the same path (an assumption, never validated, but makes sense).

FlowRouter is implemented on top of webapp, so you can definitely use both. Maybe FlowRouter also has some server-side redirect function, never tried that.

1 Like

Excellent, thanks @sashko, I knew you would have the answer :slight_smile: