Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

How to enable PWA on React + AEM SPA? (404 error)

Avatar

Level 1

I am following this tutorial: https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-spa-wknd-tutorial-develop/...

and haven't found a way to install a service worker. 

 

I did try by:

  1. Creating a service-worker.js file in the react-app/scr folder.
  2. Importing and registering it on the index.js file
    [ So far, just as any regular react app]
  3. Adding the reference to service-worker file in the clientlib.config.js file in the libs:assets:js array
    libs: {
        ...
        assets: {
        js: [
           "build/static/**/*.js",
           "build/service-worker.js"
        ],
     
     
    That got the service-worker.js from the react-app/build to the ui.apps/... /clientlibs/react-app/js/service-worker.js
    but when running the aem instance I got an 404 error on the service-worker.js file request.
     
    Screen Shot 2020-04-06 at 12.43.33 AM.png
1 Accepted Solution

Avatar

Correct answer by
Community Advisor
3 Replies

Avatar

Level 1
Hi @Suraj_Kamdi, It seems your post is about creating a custom component, but my question is about issues with a service-worker.js file.

Avatar

Correct answer by
Community Advisor