Estoy tratando de configurar mi apache para ejecutar la aplicación de reacción. Se ejecuta en localhost. Sin embargo, quiero redirigir http a https. Cuando hago eso, service-worker.js no funciona. Obtengo la excepción DOM. También he usado el certificado SSL
trabajador-servicio.js
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js"); importScripts( "/precache-manifest.7167b3346c21d4ebe11be4972eadad7c.js" ); self.addEventListener('message', (event) => { if (event.data && event.data.type === 'SKIP_WAITING') { self.skipWaiting(); } }); workbox.core.clientsClaim(); self.__precacheManifest = [].concat(self.__precacheManifest || []); workbox.precaching.precacheAndRoute(self.__precacheManifest, {}); workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/index.html"), { blacklist: [/^\/_/,/\/[^\/?]+\.[^\/]+$/], });Esta es mi configuración de Apache
El host donde se ejecuta mi aplicación
<VirtualHost *:81> ProxyPreserveHost On ServerName 10.177.218.172 RemoteIPHeader X-Client-IP ErrorLog C:\APACHE\Apache24\logs\New_error.log CustomLog C:\APACHE\Apache24\logs\New_error.log combined LogLevel debug ShibCompatValidUser Off DocumentRoot "${SRVROOT}/Example" </VirtualHost>Usar proxy inverso para obtener https
<VirtualHost *:91> SSLEngine On SSLProxyEngine On SSLCertificateFile "root.crt" SSLCertificateKeyFile "server.key" SSLHonorCipherOrder on SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA SSLProxyVerify none SSLProxyCheckPeerCN off SSLProxyCheckPeerName off RequestHeader set X-Forwarded-Proto "https" RequestHeader set X-Forwarded-Port "91" RequestHeader set REMOTE_ADDR "10.217.12.12" RequestHeader set HOST "10.217.12.12:91" <Location /> ProxyPass "http://10.217.12.12:81/" ProxyPassReverse "http://10.217.12.12/" </Location> </VirtualHost>Recibo este error cuando ejecuto 10.217.12.12:91
serviceWorker.js:97 Error during service worker registration: DOMException: Failed to register a ServiceWorker for scope ('https://10.217.12.12:91/') with script ('https://10.217.12.12:91/service- worker.js'): An SSL certificate error occurred when fetching the script.¿Alguien tiene una idea para arreglar esto?
El trabajador del servicio solo se ejecuta en modo seguro. React debe conocer la ubicación del archivo ssl. obtenga un certificado ssl para la aplicación de reacción, 1. Para linux, agregue esto a su archivo .env,
SKIP_PREFLIGHT_CHECK=true SSL_CERT_FILE=./path/to/cert SSL_KEY_FILE=./path/to/keyfile.pem HTTPS=trueo, en su paquete.json
"scripts": { "start": "set HTTPS=true && react-scripts start", "build": "react-scripts build", . ..Para ventanas,
($env:HTTPS = "true") -y (inicio npm)
lea esto para obtener más información, Reaccionar: Uso de HTTPS en desarrollo