What is a server object in AccountsServer?

I’m trying to learn how to use AccountsClient and AccountsServer.

In my server.js, I have this:

Server = new AccountsServer(Meteor.server);

and I got this error:

Error: A method named '/users/insert' is already defined

My question is what is a server object? How should I solve the problem?

This is a bit awkwardly documented at the moment (hopefully we will improve it soon) but an accounts server object is pre-created for you on Accounts.

So you don’t need to initialize the default accounts server object, you only need to do so if you need to create another one, which basically never happens.

@benjamn is there actually any situation where you would want to declare your own accounts server?

Thank you for your clarification. =)

A side-question that is related AccountsServer and AccountsClient.

I’m planning to create a centralized login for different apps. My initial thought was that I’m gonna create an Account Server using AccountsServer and connect my apps to the Account Server using AccountsClient. Am I heading to to right direction?

Yes that’s correct, except every Meteor app with the accounts-base package has an accounts server already, so you don’t need to initialize one.

1 Like