3

I've got a Shopify app that, on install and on load shows an error for a second or two before it loads okay. The error says "pages is undefined" and originates from NextJS code. This part to be exact:

function resolveDynamicRoute(pathname, pages) {
const cleanPathname = (0, _normalizeTrailingSlash).removePathTrailingSlash((0, _denormalizePagePath).denormalizePagePath(pathname));
if (cleanPathname === '/404' || cleanPathname === '/_error') {
    return pathname;
}
// handle resolving href for dynamic routes
if (!pages.includes(cleanPathname)) {
    // eslint-disable-next-line array-callback-return
    pages.some((page)=>{
        if ((0, _isDynamic).isDynamicRoute(page) && (0, _routeRegex).getRouteRegex(page).re.test(cleanPathname)) {
            pathname = page;
            return true;
        }
    });
}
return (0, _normalizeTrailingSlash).removePathTrailingSlash(pathname);
}

The error is thrown on the second if statement.
The file is found in /node_modules/next/dist/shared/lib/router/router.js, so I can't go changing stuff to this file.

I figure it has something to do with my dynamic routes, but I can't for the life of me find out what's wrong. Does somebody else know?

My routing:

 - /pages
   - _app.tsx
   - index.tsx
   - /customers
     - index.tsx
     - [customerId].tsx
   - /api
     - auth.tsx
     - graphql.tsx
     - /auth
       - callback.tsx
     - /customers
       - data_request.tsx
       - redact.tsx
     - /shop
       - redact.tsx

Screenshot of error

If any more info is needed, please let me know.

Paul van den Dool
  • 3,020
  • 3
  • 20
  • 44

0 Answers0