# Nginx 400 “Header or Cookie Too Large” error when using Auth0 SDK in Next.js project

**URL:** <https://community.auth0.com/t/nginx-400-header-or-cookie-too-large-error-when-using-auth0-sdk-in-next-js-project/193876>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [October 29, 2025, 11:49am UTC](https://community.auth0.com/t/nginx-400-header-or-cookie-too-large-error-when-using-auth0-sdk-in-next-js-project/193876 "2025-10-29T11:49:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sid2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sid2/32/60158_2.png) [@sid2](https://community.auth0.com/u/sid2)\
**Post date:** [October 29, 2025, 11:49am UTC](https://community.auth0.com/t/nginx-400-header-or-cookie-too-large-error-when-using-auth0-sdk-in-next-js-project/193876/1 "2025-10-29T11:49:59Z")

</div>

We are encountering intermittent **HTTP 400 errors** from Nginx with the message **“Request Header Or Cookie Too Large”** for some users when using the **latest Auth0 Next.js SDK** (`@auth0/nextjs-auth0`).

After investigation, this appears related to **large session cookies** generated by the SDK, as similar reports exist from other Auth0 users. We are not manually adding large cookies on our side.

Our app only uses the `/auth/profile` endpoint to fetch user profile information after login. We rely entirely on the SDK defaults for session and cookie handling.

---

<div class="post-metadata">

**Author:** ![remus.ivan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/remus.ivan/32/68771_2.png) [@remus.ivan](https://community.auth0.com/u/remus.ivan)\
**Post date:** [October 29, 2025, 6:15pm UTC](https://community.auth0.com/t/nginx-400-header-or-cookie-too-large-error-when-using-auth0-sdk-in-next-js-project/193876/3 "2025-10-29T18:15:31Z")

</div>

Hi @sid2,

Welcome to the Auth0 Community!

The default behavior of the SDK is to have the user’s sessions stored in encrypted cookies, which indeed have a fixed size limit of 8KB that can easily be surpassed, especially by the large size of the access token.

To reduce the size of the **request headers** you can try removing any unnecessary cookies and headers:

- **Review and reduce the number of scopes or additional claims requested for the Access Token.**
- **Remove any non-essential cookies being sent in the request header.**
- **If using a custom domain with a reverse proxy, review its configuration to prevent it from adding unnecessary cookies to the request.**

Also by design of the Nextjs SDK, both the ID Token, Access Token and Refresh Token will be stored in a cookie, but you can avoid storing the accesstoken ( if you do not need it for external API calls ) or the ID token by setting the `AUTH0_SESSION_STORE_ID_TOKEN` or the `AUTH0_SESSION_STORE_ACCESS_TOKEN`environment variable to `false`.

Additionally, the NextJS SDK also highlights solutions for minimizing the session cookies such as using a **custom session store**. You can check this out from the [nextjs-auth0 /EXAMPLES.md - Token Management Best Practices](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#use-a-custom-session-store).

The related KB article on the matter that worth following would be:

- [Request Header or Cookie Too Large Error](https://support.auth0.com/center/s/article/Request-Header-or-Cookie-Too-Large)
- [Next.js SDK Cookie Size is Too High](https://support.auth0.com/center/s/article/Next-js-SDK-cookie-size-is-too-high)

Thank you and please let me know if you have any other questions!  
Best regards,  
Remus

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 12, 2025, 6:15pm UTC](https://community.auth0.com/t/nginx-400-header-or-cookie-too-large-error-when-using-auth0-sdk-in-next-js-project/193876/4 "2025-11-12T18:15:46Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
