Realtime subscriptions from the server #1897
-
|
Disclosure: I'm not a security expert My Pocketbase server is in a containerized network with a nextjs server, so DB access is restricted the nextjs server and cannot be accessed from the internet. I want to stream data from the database, to a server side component, and then to a client browser. However, the server side component cannot subscribe to changes because it doesn't have EventSource access. My alternative seems to be interval polling, but subscriptions are just too alluring. I suspect it can be accomplished using the PocketBase framework, but I am unsure. It seems very few people have this question. My questions are: If you have other insights, please let me know. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It depends on your use case and the desired workflow. Based on your description it seems that the Next.js server is acting as a proxy/middleware layer for the PocketBase API, and in this case it should be OK to use it this way.
Yes, in both cases. If you want to use the SDK and the realtime service in node, you can load an // npm install eventsource --save
import eventsource from 'eventsource';
global.EventSource = eventsource;
...(this and other node caveats could be found in https://github.com/pocketbase/js-sdk#nodejs-via-npm) You can also directly connect to the Realtime APIs following https://pocketbase.io/docs/api-realtime/. |
Beta Was this translation helpful? Give feedback.
It depends on your use case and the desired workflow. Based on your description it seems that the Next.js server is acting as a proxy/middleware layer for the PocketBase API, and in this case it should be OK to use it this way.
Yes, in both cases.
If you want to use the SDK and the realtime service in node, you can load an
EventSourcepolyfill:(this and other node caveats could be found in https://github.com/pocketba…