NOaMTL
NOaMTL

Reputation: 193

server-side only action in meteor (accessible on client-side)

I am learning meteor and did the to-do project in meteor's tutorial. I was wondering how to hide some data from the client since files outside the server folder can be seen from the client. Let's say a user does register to the app and want to call an external api to fetch some data and i use a secret to do so, and I dont want to expose this secret. Then I want to add this data that i got to the user collection. Actually I use Meteor methods (ran by client and server).

Thank you.

Upvotes: 0

Views: 70

Answers (1)

Michel Floyd
Michel Floyd

Reputation: 20227

You can do this in a Meteor Method. Put the code for this method in /server and it won't be shared with the client. You call the method from the client using Meteor.call()

Also note that it's good practice to put secrets in a settings file and to manage this file outside of your version control system. See Making Use of Settings.json

Upvotes: 0

Related Questions