service worker does not install reactjs











up vote
0
down vote

favorite












Good evening, I'm trying to work with Reactjs and ServiceWorker to create a PWA but when creating a new project everything seems to work fine but when running npm run build and dispatch the result with npm's http-server opens the application correctly but the browser never records that there is a service worker.



I have already dealt with 3 projects and different browsers but everything remains the same.
The projects are as they are installed with create-react-app.



Does anyone know why the service worker is not installed?



Attached image of how it is not registered by the browser even though it is in the build folder.



If I do this without using react as proof with a simple service worker file if I can register it but with reacrt I do not get it that way.



sw not registered



Thanks.










share|improve this question






















  • You might need to disable the HTTPS security verification. Services workers only work in HTTPS.
    – ChrisR
    yesterday















up vote
0
down vote

favorite












Good evening, I'm trying to work with Reactjs and ServiceWorker to create a PWA but when creating a new project everything seems to work fine but when running npm run build and dispatch the result with npm's http-server opens the application correctly but the browser never records that there is a service worker.



I have already dealt with 3 projects and different browsers but everything remains the same.
The projects are as they are installed with create-react-app.



Does anyone know why the service worker is not installed?



Attached image of how it is not registered by the browser even though it is in the build folder.



If I do this without using react as proof with a simple service worker file if I can register it but with reacrt I do not get it that way.



sw not registered



Thanks.










share|improve this question






















  • You might need to disable the HTTPS security verification. Services workers only work in HTTPS.
    – ChrisR
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Good evening, I'm trying to work with Reactjs and ServiceWorker to create a PWA but when creating a new project everything seems to work fine but when running npm run build and dispatch the result with npm's http-server opens the application correctly but the browser never records that there is a service worker.



I have already dealt with 3 projects and different browsers but everything remains the same.
The projects are as they are installed with create-react-app.



Does anyone know why the service worker is not installed?



Attached image of how it is not registered by the browser even though it is in the build folder.



If I do this without using react as proof with a simple service worker file if I can register it but with reacrt I do not get it that way.



sw not registered



Thanks.










share|improve this question













Good evening, I'm trying to work with Reactjs and ServiceWorker to create a PWA but when creating a new project everything seems to work fine but when running npm run build and dispatch the result with npm's http-server opens the application correctly but the browser never records that there is a service worker.



I have already dealt with 3 projects and different browsers but everything remains the same.
The projects are as they are installed with create-react-app.



Does anyone know why the service worker is not installed?



Attached image of how it is not registered by the browser even though it is in the build folder.



If I do this without using react as proof with a simple service worker file if I can register it but with reacrt I do not get it that way.



sw not registered



Thanks.







reactjs service-worker






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









OscarDev

829




829












  • You might need to disable the HTTPS security verification. Services workers only work in HTTPS.
    – ChrisR
    yesterday


















  • You might need to disable the HTTPS security verification. Services workers only work in HTTPS.
    – ChrisR
    yesterday
















You might need to disable the HTTPS security verification. Services workers only work in HTTPS.
– ChrisR
yesterday




You might need to disable the HTTPS security verification. Services workers only work in HTTPS.
– ChrisR
yesterday












2 Answers
2






active

oldest

votes

















up vote
0
down vote













Does you import your SW in the App entry point module? Example:



// index.js:

import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();





share|improve this answer




























    up vote
    0
    down vote













    Thanks partners. I was able to solve it by modifying in line src / index.js the line 1 that I had:



    serviceWorker.unregister();



    By: serviceWorker.register();



    And now it works.



    Regards!






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372643%2fservice-worker-does-not-install-reactjs%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      Does you import your SW in the App entry point module? Example:



      // index.js:

      import registerServiceWorker from './registerServiceWorker';

      ReactDOM.render(<App />, document.getElementById('root'));
      registerServiceWorker();





      share|improve this answer

























        up vote
        0
        down vote













        Does you import your SW in the App entry point module? Example:



        // index.js:

        import registerServiceWorker from './registerServiceWorker';

        ReactDOM.render(<App />, document.getElementById('root'));
        registerServiceWorker();





        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          Does you import your SW in the App entry point module? Example:



          // index.js:

          import registerServiceWorker from './registerServiceWorker';

          ReactDOM.render(<App />, document.getElementById('root'));
          registerServiceWorker();





          share|improve this answer












          Does you import your SW in the App entry point module? Example:



          // index.js:

          import registerServiceWorker from './registerServiceWorker';

          ReactDOM.render(<App />, document.getElementById('root'));
          registerServiceWorker();






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          Sviat Kuzhelev

          931215




          931215
























              up vote
              0
              down vote













              Thanks partners. I was able to solve it by modifying in line src / index.js the line 1 that I had:



              serviceWorker.unregister();



              By: serviceWorker.register();



              And now it works.



              Regards!






              share|improve this answer

























                up vote
                0
                down vote













                Thanks partners. I was able to solve it by modifying in line src / index.js the line 1 that I had:



                serviceWorker.unregister();



                By: serviceWorker.register();



                And now it works.



                Regards!






                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Thanks partners. I was able to solve it by modifying in line src / index.js the line 1 that I had:



                  serviceWorker.unregister();



                  By: serviceWorker.register();



                  And now it works.



                  Regards!






                  share|improve this answer












                  Thanks partners. I was able to solve it by modifying in line src / index.js the line 1 that I had:



                  serviceWorker.unregister();



                  By: serviceWorker.register();



                  And now it works.



                  Regards!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  OscarDev

                  829




                  829






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372643%2fservice-worker-does-not-install-reactjs%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                      SQL update select statement

                      'app-layout' is not a known element: how to share Component with different Modules