shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.89k stars 325 forks source link

Application is not preaching and not working on offline with base path #314

Closed developerajendra closed 2 years ago

developerajendra commented 2 years ago

Hi,

I am using basepath in next JS Application but deploying the Application on server I am not using any subdomain, instead I am replacing base path with empty string to access the pages / assets (this is my project requirement). While running the application on browser the index.html is cached within the defined based path on next JS (ex:start-url:http://localhost:4001 as /base-path which is resolving index.html ). When I try to run my application without base-path it's not working on offline mode.

My PWA config:

{
basePath,
pwa: {
        dest: `public`,
        register: true,
        skipWaiting: true,
        subdomainPrefix: `${basePath}/`,
        buildExcludes: [/middleware-manifest.json$/],
    }  
}

My next and PWA Version:

 "next": "12.0.4",
    "next-pwa": "5.4.1",

My server code to replace base path:

if(uri.includes('/base-path')) {
         req.url = '/';
    }

      if (!uriLastPart.includes("htm")) {
        if (uriLastPart.includes('.')) {
            req.url = uri.replace('corp-static/', "");
        }
    }
Please help me with this. 
developerajendra commented 2 years ago

Issue with base path, I have cloned the next-pwa to local and removed the basepath and included the scope as: './' and this is solving my problem