I have been using the new TWebPushNotifications component and have successfully run the demo.
However, want I now want to do is what Bruno did in the introduction video, that is, host the push server on a server machine and send notifications to non-local clients.
I don't understand how to do this. What needs to be configured to get a server to interface with a non-local client?
I have done those steps, but I still have a problem.
To illustrate my setup, I have my client folder hosted thus (the underscore is not present, of course): https:_//myhost.com/WebPush/WebClient/dist
The server sits at: https:_//myhost.com/WebPush/Server/bin
The endpoint addresses you mentioned now all point to: https: _//myhost.com/WebPush/endpoint
However when trying to access this from a non-local machine, I get the following the message:
Access to fetch at 'https_://myhost.com/vapidPublicKey' from origin 'http://localhost:8000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Have I missed a step or is there something incorrect in my setup?
It should not be an issue to access the push server from a locally hosted web app, at least from origin 'http://localhost:8000'implies that is what you tried to do.
Are you sure the TWebPushNotifications URL properties pointing to the correct endpoints? Normally it should be path to server + endpoint. If you server is running and available via https:_//myhost.com/WebPush/Server/bin then I'd expect the endpoints to be something like https:_//myhost.com/WebPush/Server/bin/endpoint
You can verify this by opening the vapidPublicKey endpoint from your browser directly as a link. It should return the public VAPID key as a result. If that doesn't happen, the endpoint you are trying to use for the VAPID key is incorrect.
Thanks for that. Yes, it seems my URLs to the endpoints were not configured correctly and I have now fixed those.
The problem I have identified now is the server is not being hosted but only running locally (hence why I can access it from the server machine but not an external one). If I do the vapidPublicKey check, it only returns if I access it via localhost.
Have I missed something with how one configures the server? I was led to believe that if I put it in domain_.com/WebPush/Server/bin, I would be able to connect to it with a client from another machine? But this does not happen; it hosts internally.
Is there some setting I'm missing or am I doing something wrong?
The process would be similar to deploying any other Indy-based server. Most likely it's not the server you need to configure (unless it's certificate related), but your firewall settings of your machine to let through the incoming connections for a given port.