clerk / example-cypress-nextjs

Example repo using Clerk, Cypress and NextJS
4 stars 1 forks source link

Update to include authMiddleware #4

Closed knightjdr closed 3 days ago

knightjdr commented 1 year ago

Can this example be updated to include middleware following the getting started guide for nextjs?

import { authMiddleware } from "@clerk/nextjs";

export default authMiddleware();

export const config = {
  matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};

Upgrading @clerk/nextjs to 4.19.1, adding the above middleware, and running npm run dev results in

error - (middleware)/node_modules/@clerk/nextjs/dist/esm/server-helpers.client.js (2:0) @ <unknown>
error - authMiddleware() can only be used in a server environment.
anagstef commented 3 days ago

Hello! We have updated our example repo. The update includes the latest versions of all packages, Custom Commands from the @clerk/testing package, and Testing tokens. The new example uses the latest clerkMiddleware.

You can learn more here: https://clerk.com/docs/testing/cypress