Meteor.loginWithPassword with new AccountsClient does not work

I am trying to split my app into a backend app and a frontend app. The size of the JS payload is increasing due to weight in the backend, and I’d like to streamline the experience for my frontend users.

I am trying to make my frontend auth against the backend users database, using:

Meteor.backend = DDP.connect( Meteor.settings.public.backend.ddpUrl );
Accounts = new AccountsClient({
connection: Meteor.backend
});

When I run Meteor.loginWithPassword, it queries against the frontend server instead of the backend server. I believe this is because Accounts is scoped into accounts-password in a way that prevents me from changing the reference to the new AccountsClient.

I have also tried:

BackendAccounts = new AccountsClient({
connection: Meteor.backend
});
Accounts.connection = BackendAccounts.connection;

When I run loginWithPassword with the above code, I receive undefined for both the error and result response, and no login takes place, despite the DDP communication to the backend server looking correct.

Has anyone successfully used AccountsClient and loginWithPassword to login to a different Meteor server? Or do I need to roll my own loginWithPassword replacement?

3 Likes