Next-pwa non-stop refresh on offline mode

91 views Asked by At

I'm using Next-PWA and Next-translate

I used middleware to support multi-tenant (middleware rewrites user's requests to it's organization's page) it's the abridged version of the middleware:

export async function middleware(req: NextRequest) {
    const url = req.nextUrl.clone();
    url.pathname = `/organizations/${viewport}/${req.headers.get('host')}${url.pathname}`;
    return NextResponse.rewrite(url);
}

We wanted to cache the viewport, organization(host), and the path.

The point is that next-translate rewrite request to its language (If we don't specify any languages it sends the user to /default language)

And the problem is that in offline mode when we can see the cached root page it tries to get the default page and it causes a non-stop refresh on the page.

I set dynamicStartUrlRedirect: '/default' in PWA config I tried additionalManifestEntries too Actually, it cached the default page but doesn't use it! In the online mode: enter image description here

In the offline mode(With non-stop refresh): enter image description here enter image description here

Here is the cached page: enter image description here

Versions next-pwa: "^5.6.0" next:"12.2.0" next-translate: "^1.4.0"

1

There are 1 answers

0
Navid Nourani On BEST ANSWER

I changed the Next version to 12.3.2 and it works fine now!