Middleware doesn't run in root directory

Open Beginner friendly
#118 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Active
Tech stack
nextjs
Domain
documentation

Research direction

Review the linked Supabase Auth Next.js server-side documentation and its middleware placement guidance. Verify the documented behavior for Next.js 14 through 15, especially projects using a src directory, and update the page so the middleware location is unambiguous. Done means the instructions match the shown project structure and avoid the reported authentication errors.

Written by the indexing model from the issue text.

Description

documentation stale

Improve documentation

Link

[
Add a link to the page which needs improvement (if relevant)]
(https://supabase.com/docs/guides/auth/server-side/nextjs?queryGroups=router&router=app)

Describe the problem

middleware doesn't run in root_folder/middleware.ts for next js 14 to 15

the middleware.ts file should be in
src/middleware.ts for at least nextjs 14 to 15

/my-next-app
├─ src/
│ ├─ middleware.js <-- here
│ └─ app/
├─ next.config.js
└─ package.json

not root/middleware.ts this causes all sorts of authentication errors

Dominant language
TypeScript
Stars
207
Forks
32
Avg merge
14h 56m
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/ssr

All issues in supabase/ssr

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.