Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middleware does not run when concurrentFeatures is enabled #31654

Closed
saurabhguptarock opened this issue Nov 21, 2021 · 2 comments
Closed

Middleware does not run when concurrentFeatures is enabled #31654

saurabhguptarock opened this issue Nov 21, 2021 · 2 comments
Assignees
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware.

Comments

@saurabhguptarock
Copy link

saurabhguptarock commented Nov 21, 2021

What version of Next.js are you using?

12.0.5-canary.5

What version of Node.js are you using?

14.18.1

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

Middleware does not run and redirects user.

Expected Behavior

Middleware should redirect to login page

To Reproduce

module.exports = {
  images: {
    deviceSizes: [640],
    domains: ["avatars.dicebear.com"],
    formats: ["image/avif", "image/webp"],
  },
  createRoot: true,
  swcMinify: false,
  experimental: {
    reactRoot: true,
    concurrentFeatures: true,
    serverComponents: true,
  },
};

_middleware.tsx

import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";

export const middleware = (req: NextRequest) => {
  const cookie = req.cookies["auth"];

  if (!cookie) {
    return NextResponse.redirect("/login");
  }
};
@saurabhguptarock saurabhguptarock added the bug Issue was opened via the bug report template. label Nov 21, 2021
@timneutkens timneutkens added area: Concurrent Features Middleware Related to Next.js Middleware. labels Nov 26, 2021
@huozhi huozhi linked a pull request Dec 22, 2021 that will close this issue
@shuding
Copy link
Member

shuding commented Apr 8, 2022

Duplicate of #31803, will track there.

@shuding shuding closed this as completed Apr 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. Middleware Related to Next.js Middleware.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants