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

fix(middleware): use `includes()` for NextAuth pages

Open Juneezee opened this issue 3 years ago โ€ข 1 comments

Something went wrong with #5085, GitHub wasn't updating the PR with the new commits

โ˜•๏ธ Reasoning

Some users could be setting their signIn and error pages option to / to disable the automatically generated pages, as suggested in https://github.com/nextauthjs/next-auth/discussions/2330#discussioncomment-1678298.

This PR reverts the behaviour for matching signIn and error pages in handleMiddleware to pre-v4.10.3.

EDIT:

const signInPage = "/"
const errorPage = "/"
const publicPaths = [signInPage, errorPage, "/_next", "/favicon.ico"]

// pathname = "/protected" will always return true
publicPaths.some((p) => pathname.startsWith(p))

Fixes: aedabc8d ("fix: avoid redirect on always public paths")

๐Ÿงข Checklist

  • [ ] Documentation
  • [x] Tests
  • [x] Ready to be merged

๐ŸŽซ Affected issues

๐Ÿ“Œ Resources

Juneezee avatar Aug 06 '22 08:08 Juneezee

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

1 Ignored Deployment
Name Status Preview Updated
next-auth โฌœ๏ธ Ignored (Inspect) Sep 18, 2022 at 3:52AM (UTC)

vercel[bot] avatar Aug 06 '22 08:08 vercel[bot]

Thanks again @Juneezee! ๐Ÿ™Œ

ThangHuuVu avatar Sep 18 '22 04:09 ThangHuuVu