Detecting admin context in hooks #12901
Unanswered
anatolykopyl
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to be able to tell if a request is being made from the admin panel or from elsewhere.
My use case is that I have to replace certain placeholders across all documents, for example every occurrence of
%employee-count%
should be replaced with a value from a specific collection. The problem is that once a field with this placeholder is created, the placeholder will never be visible in the admin panel, since if anafterRead
hook replaces it with a number, it does so both on the website and in the admin panel.The workaround I currently have is that I check for the
req.payloadAPI
inside of the hook to not belocal
. But this only works because I don't use the local API in my actual website.Beta Was this translation helpful? Give feedback.
All reactions