Skip to content

request.cookies information missing when using isReqWrapper #9045

@JulianJorgensen

Description

@JulianJorgensen

Environment

System:
OS: macOS 14.0
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 258.79 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
Yarn: 1.10.1 - /opt/local/bin/yarn
npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Chrome: 119.0.6045.105
Safari: 17.0

npmPackages:
next: ^14.0.1 => 14.0.1
next-auth: ^5.0.0-beta.3 => 5.0.0-beta.3
react: ^18.2.0 => 18.2.0

npmPackages:
@auth/firebase-adapter: ^1.0.0 => 1.0.0

Reproduction URL

https://github.com/JulianJorgensen/next-auth-v5-custom-middleware-bug

Describe the issue

In v5, when using the custom middleware wrapper as such:

export default auth((req) => {
  console.log('req.cookies', req.cookies)
  return intlMiddleware(req)
})

req.cookies is undefined.
However, it is required by my other middleware intlMiddleware.

How to reproduce

Install v5 and set middleware.js as this:

import { auth } from 'auth';

export default auth((req) => {
  console.log('req.cookies', req.cookies)
  return req
})

Expected behavior

auth() used as a middleware wrapper should return the original request but with just auth appended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriorityPriority fix or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions