diff --git a/.changeset/selfish-pens-laugh.md b/.changeset/selfish-pens-laugh.md new file mode 100644 index 0000000000..b0c0e5b0ab --- /dev/null +++ b/.changeset/selfish-pens-laugh.md @@ -0,0 +1,5 @@ +--- +"@clerk/nextjs": patch +--- + +Update the error thrown by auth() or getAuth() to indicate that if the /src directory exists, then the middleware.ts file needs to be placed inside it, otherwise the middleware will not run. diff --git a/packages/nextjs/src/server/errors.ts b/packages/nextjs/src/server/errors.ts index cb9488bce8..09c29cf0f0 100644 --- a/packages/nextjs/src/server/errors.ts +++ b/packages/nextjs/src/server/errors.ts @@ -28,11 +28,16 @@ Alternatively, you can set your own ignoredRoutes. See https://clerk.com/docs/ne (This log only appears in development mode) `; -export const getAuthAuthHeaderMissing = () => - 'You need to use "authMiddleware" (or the deprecated "withClerkMiddleware") in your Next.js middleware file. You also need to make sure that your middleware matcher is configured correctly and matches this route or page. See https://clerk.com/docs/quickstarts/get-started-with-nextjs'; +export const getAuthAuthHeaderMissing = () => authAuthHeaderMissing('getAuth'); -export const authAuthHeaderMissing = () => - "Clerk: auth() was called but it looks like you aren't using `authMiddleware` in your middleware file. Please use `authMiddleware` and make sure your middleware matcher is configured correctly and it matches this route or page. See https://clerk.com/docs/quickstarts/get-started-with-nextjs"; +export const authAuthHeaderMissing = (helperName = 'auth') => + `Clerk: ${helperName}() was called but Clerk can't detect usage of authMiddleware(). Please ensure the following: +- authMiddleware() is used in your Next.js Middleware. +- Your Middleware matcher is configured to match this route or page. +- If you are using the src directory, make sure the Middleware file is inside of it. + +For more details, see https://clerk.com/docs/quickstarts/get-started-with-nextjs. +`; export const clockSkewDetected = (verifyMessage: string) => `Clerk: Clock skew detected. This usually means that your system clock is inaccurate. Clerk will continuously try to issue new tokens, as the existing ones will be treated as "expired" due to clock skew.