I am struggling to make my Server Side Rendering and Service Worker cooperate on server Side.
Information regarding localhost -> Working
This is working as expected. The service worker works and updates my app on every update. Moreover; a curl localhost:8082
send me back my info.
I start my app with the following command : npm run ssr
"ssr": "npm run build:ssr && npm run serve:ssr",
"build:ssr": "npm run build:client-and-server-bundles",
"serve:ssr": "node dist/server.js",
"build:client-and-server-bundles": "ng build --prod && npm run webpack:server",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors"
Information regarding production: -> Not Working
Website is over HTTPS : https://airdropers.io Website process is running on a close port and has HAPROXY redirecting traffic from 443 to the port of the webserver
Issue visible on Webserver logs : Could not subscribe to notifications Error: Service workers are disabled or not supported by this browser
Extra info :
Node js on localhost and production are the same: v9.0.0 I build on production with the following process :
- git pull
- npm run build:ssr
- pm2 start dist/server.js
UPDATE 23/02/2019
I have now a deeper understanding. My issue is that I start my SSR/PWA server with a node command such as "node dist/server.js".
From my understanding "node dist/server.js" is not working for Service Worker (PWA) I quote (https://angular.io/guide/service-worker-getting-started)
Because ng serve does not work with service workers, you must use a separate HTTP server to test your project locally. You can use any HTTP server. The example below uses the http-server package from npm. To reduce the possibility of conflicts and avoid serving stale content, test on a dedicated port and disable caching.
I can not launch is with http-server dist/browser
because I will loose the SSR Capability.
How can I start my PWA / SSR Server ?
What command shall I use?
What build shall I do?
UPDATE 24/02/2019
As mentioned by @Gökhan Kurt the service worker is not working properly with my SSR server. I need SSR for SEO and I need a service worker for Browser Push Notification. What solution do I have to handle Browser User Push Notification? A third party lib such as One Signals?
Any ideas suggestions are well welcomed to help me make that work. Thank you for support, Alex