Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): Warn about misplaced middleware file when using auth or getAuth #1908

Merged
merged 3 commits into from
Oct 18, 2023

Conversation

nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Oct 17, 2023

For NextJS 13 application, if the /src directory is used then the middleware file needs to be nested under it, otherwise the middleware will not run.

This is a very common user error - this commit updates the error message to list moving middleware under /src as a potential fix.

Fixes SDK-818

Description

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

@nikosdouvlis nikosdouvlis requested a review from a team as a code owner October 17, 2023 20:57
@changeset-bot
Copy link

changeset-bot bot commented Oct 17, 2023

🦋 Changeset detected

Latest commit: d8fd2fd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

packages/nextjs/src/server/errors.ts Outdated Show resolved Hide resolved
packages/nextjs/src/server/errors.ts Outdated Show resolved Hide resolved
…getAuth

For NextJS 13 application, if the `/src` directory is used then the middleware file needs to be nested under it, otherwise the middleware will not run.

This is a very common user error - this commit updates the error message to list moving middleware under /src as a potential fix.
Co-authored-by: Bryce Kalow <bryce@clerk.dev>
@nikosdouvlis nikosdouvlis merged commit 6576ac4 into main Oct 18, 2023
3 checks passed
@nikosdouvlis nikosdouvlis deleted the nikos/improve-auth-error branch October 18, 2023 08:01
@clerk-cookie clerk-cookie mentioned this pull request Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants