Hi Velo forum,
I’ve been digging through the API docs and examples of wix-realtime API, but cannot find an answer to a behavior I’m noticing with wix-realtime.
I can only get wix-realtime working in my front-end site (i.e. receiving updates on a subscribed channel) when the publish() function is triggered from a front-end action. Backend actions (such as having a publish() function in a collection afterInsert, or a publish() function in a backend http-functions.js is not triggering a channel update on the live site, only preview).
My question: does wix-realtime work with publish() executions triggered by a backend function?
Example:
I have an afterInsert datahook for one of my collections, dealFeed . I set up the afterInsert per the following wix-realtime tutorial (https://www.wix.com/velo/example/real-time-notifications-for-real-estate) to publish() to the channel and I also subscribed to the channel on my front-end page similar to the tutorial.
When I insert data into the collection (via back-end http-functions.js, using options {“suppressAuth” : true , “suppressHooks” : false } ) the publish() function in my afterInsert datahook does not fire and so I do not have the channel update come through on my front-end page.
In contrast… when I have a button on my front-end page to insert data into the same collection, the publish() function in afterInsert (in data.js) is triggered and I see the channel update on my front-end page.
Can wix-realtime channel message only be triggered by front-end actions? The only examples I have seen involved a front-end action, even when an afterInsert hook is used (technically a back-end function, but again, only working when fired from a front-end insert).
Thank you!