Skip to content

Access Collection Internally from Hook #557

Answered by jmikrut
peniswafflexd asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @peniswafflexd — this is super easily solved actually via a few options.

In any case, and as you probably know already, you should restrict read access control to any collections that should not be publicly readable. However, once access is restricted, you can:

  1. First authenticate via logging in with a user that should have read access, and then using the returned token to authenticate in your fetch
  2. Enable API Keys on your Users collection(s), generate a key, and use that
  3. Use the Local API to read your restricted docs. By default, access control is bypassed while using the Local API so you won't have any problems. All you have to do is payload.find({ /* options here */ }). This is how…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@peniswafflexd
Comment options

@jmikrut
Comment options

Answer selected by peniswafflexd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants