Insert failed: Access denied

I want to insert a piece of data (let’s say, a post) in my database. I called Posts.insert() on the client side and I get this message in my browser console “insert failed: Access denied”.
I added Post.allow :

Posts.allow({
insert: function (userId, doc) {
return true;
}
});

But I still have the same message. So what I have to do ?

Have you put that allow rule in your server code?

1 Like

I have to put it in server code ?

Yes. Server code cannot be tampered with, so it’s the only place you can “open holes”.

Edit: I should add that it’s hard to write good allow/deny rules and it’s usually much easier (and safer) to call a Meteor method.

Working now by changing Post.allow in the server side.
Thank you ^^

2 Likes