next-learn icon indicating copy to clipboard operation
next-learn copied to clipboard

Chapter 14: Adding Authentication – Dashboard still accessible without login.

Open OAleksandr opened this issue 1 year ago • 5 comments

Hello everyone,

In Chapter 14, Adding Authentication (https://nextjs.org/learn/dashboard-app/adding-authentication), I followed all the instructions. However, I can still access the dashboard directly at http://localhost:3000/dashboard even when I’m not logged in. It should redirect to the login page, but instead, I can see the dashboard content.

Is anyone else experiencing the same issue?

OAleksandr avatar Nov 09 '25 23:11 OAleksandr

Yes I am having the same issue, did you able to fix?

YogeshSanchania avatar Nov 12 '25 07:11 YogeshSanchania

Also having this issue. I've seen others reference middleware.ts so maybe that file is missing from the tutorial? Or possibly the proxy matcher is incorrect but I'm not sure what it should look like instead.

tjhaskel avatar Nov 13 '25 00:11 tjhaskel

Also having this issue. I've seen others reference middleware.ts so maybe that file is missing from the tutorial? Or possibly the proxy matcher is incorrect but I'm not sure what it should look like instead.

Good point about middleware.ts. However, the middleware file convention has been deprecated and renamed to proxy.

https://nextjs.org/docs/app/api-reference/file-conventions/proxy

OAleksandr avatar Nov 13 '25 03:11 OAleksandr

It looks like the issue is due to the Next.js version. The tutorial project installed an older Next.js version where middleware.ts is still the convention, while the tutorial assumes proxy.ts (Next 16+). If you rename your proxy.ts file to middleware.ts, authentication will work correctly again.

The problem comes from package.json using "next": "latest", which doesn’t actually install v16 — probably because other dependencies prevent the upgrade. Manually updating it to:

"next": "^16.0.1"

fixes the issue.

sanderboers48 avatar Nov 13 '25 08:11 sanderboers48

It looks like the issue is due to the Next.js version. The tutorial project installed an older Next.js version where middleware.ts is still the convention, while the tutorial assumes proxy.ts (Next 16+). If you rename your proxy.ts file to middleware.ts, authentication will work correctly again.

The problem comes from package.json using "next": "latest", which doesn’t actually install v16 — probably because other dependencies prevent the upgrade. Manually updating it to:

"next": "^16.0.1" fixes the issue.

Ohh, cool — I renamed proxy.ts to middleware.ts and it’s working now. Thanks so much for your help!

OAleksandr avatar Nov 14 '25 04:11 OAleksandr