Skip to content

auth callback is never called in middleware #13063

@adriancuadrado

Description

@adriancuadrado

Environment

  System:
    OS: Linux 6.11 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    Memory: 1.91 GB / 7.10 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 22.13.1 - ~/.nvm/versions/node/v22.13.1/bin/node
    npm: 11.4.0 - ~/.nvm/versions/node/v22.13.1/bin/npm
  Browsers:
    Chrome: 137.0.7151.103
  npmPackages:
    next: 15.3.4 => 15.3.4 
    next-auth: ^5.0.0-beta.28 => 5.0.0-beta.28 
    react: ^19.0.0 => 19.1.0

Reproduction URL

https://github.com/adriancuadrado/authjs-middleware-bug

Describe the issue

import { auth } from "@/auth";

export default auth(() => {
  console.log("Hello world from app/middleware.ts");
});

That "Hello world" message is never displayed. Therefore, the middleware is never run.

How to reproduce

Run npm run dev, go to http://localhost:3000/ and check the logs.

Expected behavior

According to this article, middleware.ts should run. But it doesn't regardless of whether there is an authorized callback in auth.ts or not:

You can also use the auth method as a wrapper if you’d like to implement more logic inside the middleware.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions