next.js: [NEXT-1183] compress: false and middleware causes blank page in development

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64
    Binaries:
      Node: 16.19.0
      npm: 8.19.3
      Yarn: 1.22.19
      pnpm: N/A
    Relevant packages:
      next: 13.3.1-canary.19
      eslint-config-next: 13.3.0
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

Middleware / Edge (API routes, runtime)

Link to the code that reproduces this issue

https://github.com/dottodot/next-compress-middleware

To Reproduce

run yarn dev and you’ll see you get a blank page remove compress: false and the app loads correctly

Describe the Bug

When compress: false is set in next.config and middleware.ts is added in the route the app will load blank, however it’s fine after running build

Expected Behavior

compress should not have an impact on middleware.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1183

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 16
  • Comments: 16 (4 by maintainers)

Most upvoted comments

@harry-atk It’s not a performance issue for us, but we can’t use compress: true in production because we use a CDN that can’t handle gzipped content

FIXED, the issue was related to layout.tsx, it was inside dynamic routing . so I moved layout.tsx out of dynamic routing and now it works fine

I didn’t use compress, but I had the following config in the middleware which caused the blank page.

This config was copied from the nextjs docs, when I removed It the blank page was resolved

  matcher: [
    /*
     * Match all request paths except for the ones starting with:
     * - api (API routes)
     * - _next/static (static files)
     * - _next/image (image optimization files)
     * - favicon.ico (favicon file)
     */
    {
      source: '/((?!api|_next/static|_next/image|favicon.ico).*)',
      missing: [
        { type: 'header', key: 'next-router-prefetch' },
        { type: 'header', key: 'purpose', value: 'prefetch' },
      ],
    },
  ],
}

I am seeing this issue regardless of the value of compress

Dynamic routes with a base path config and middleware file. All of my Next Links navigate to a blank/white page.

For me, I get a client side error message about redirection at v13.2.5-canary.27 and with v13.2.5-canary.28 I get the white screen. All previous canary releases work without this problem.