[PR #3135] [MERGED] docs(NextJS): Improve middleware example to be more secure #4664

Closed
opened 2026-03-13 11:54:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3135
Author: @ping-maxwell
Created: 6/22/2025
Status: Merged
Merged: 6/22/2025
Merged by: @Bekacru

Base: mainHead: docs/nextjs/improve-mw-example


📝 Commits (2)

  • cf0f0cd docs(NextJS): Improve middleware example to be more secure
  • a49f34f Update docs/content/docs/integrations/next.mdx

📊 Changes

1 file changed (+30 additions, -0 deletions)

View changed files

📝 docs/content/docs/integrations/next.mdx (+30 -0)

📄 Description

Users can skim code without reading the text, and LLMs can read code and miss-understand context correctly. Our current middleware example only checks for existence of a cookie, and doesn't validate it.

While we do warn users this isn't secure, some users has raised concern in a Github issue saying it's not obvious enough for users who skim.

Also we don't provide examples on how to authenticate users on each route, we only show middleware optimistic check examples.

Closes https://github.com/better-auth/better-auth/pull/3135


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/3135 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 6/22/2025 **Status:** ✅ Merged **Merged:** 6/22/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `docs/nextjs/improve-mw-example` --- ### 📝 Commits (2) - [`cf0f0cd`](https://github.com/better-auth/better-auth/commit/cf0f0cd23dfce0f691d65b786e8107f17c088a52) docs(NextJS): Improve middleware example to be more secure - [`a49f34f`](https://github.com/better-auth/better-auth/commit/a49f34f40d6a8a3a2e0b84d3ee0fd30d13042532) Update docs/content/docs/integrations/next.mdx ### 📊 Changes **1 file changed** (+30 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/integrations/next.mdx` (+30 -0) </details> ### 📄 Description Users can skim code without reading the text, and LLMs can read code and miss-understand context correctly. Our current middleware example only checks for existence of a cookie, and doesn't validate it. While we do warn users this isn't secure, some users has raised concern in a Github issue saying it's not obvious enough for users who skim. Also we don't provide examples on how to authenticate users on each route, we only show middleware optimistic check examples. Closes https://github.com/better-auth/better-auth/pull/3135 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 11:54:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#4664