-
Notifications
You must be signed in to change notification settings - Fork 62
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
withClerkMiddleware error when changing trcp.ts #23
Comments
I'm having the same issue. Restarting everything fixed it for me. |
Exact same issue, i've already restarted everything and keeps failing, any suggestion? |
im having the same issue too |
Delete node_modules folder and rerun |
Had the same issue ended up changing the matcher in middleware.ts, as suggested in this thread (https://www.answeroverflow.com/m/1099604152130220052) by James Perkins: |
Same issue here Solution from James Perkins worked perfectly. |
This works for me This was my error ❌ tRPC failed on : 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 |
I'm still getting the error after I switch to
|
We're using a soon-to-be deprecated API. I wish there was an app that can auto-generate tutorials with the latest API. The Clerk documentation isn't clear about which version the documentation is for. I am copying and pasting directly from the Clerk Middleware documentation. I've tried the withClerkMiddleware code, I've tried copying and pasting the code from chirp, and I've also tried the new authMiddleware that works with Next.JS 13's app. Then I did npm update -g
npm audit --force and now there are 0 vulnerabilities using "@clerk/nextjs": "^4.11.7" and there is no authMiddleware and using the code from the above fix and linked Clerk Documentation didn't help. Here is the full {
"name": "chirp",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "next build",
"dev": "next dev",
"postinstall": "prisma generate",
"lint": "next lint",
"start": "next start",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@clerk/nextjs": "^4.11.7",
"@prisma/client": "^4.9.0",
"@tanstack/react-query": "^4.20.2",
"@trpc/client": "^10.9.0",
"@trpc/next": "^10.9.0",
"@trpc/react-query": "^10.9.0",
"@trpc/server": "^10.9.0",
"@upstash/ratelimit": "^0.4.0",
"@upstash/redis": "^1.20.1",
"dayjs": "^1.11.7",
"next": "^13.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hot-toast": "^2.4.0",
"superjson": "1.9.1",
"zod": "^3.21.4"
},
"devDependencies": {
"@types/eslint": "^8.21.1",
"@types/node": "^18.14.0",
"@types/prettier": "^2.7.2",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"autoprefixer": "^10.4.7",
"eslint": "^8.34.0",
"eslint-config-next": "^13.2.1",
"postcss": "^8.4.14",
"prettier": "^2.8.1",
"prettier-plugin-tailwindcss": "^0.2.1",
"prisma": "^4.13.0",
"tailwindcss": "^3.2.0",
"typescript": "^4.9.5"
},
"ct3aMetadata": {
"initVersion": "7.7.0"
}
} I then copied and pasted the package.json from the chirp demo and it cuased the env.mjs file to blow up so I replaced that with the env.js from chirp, and still no go. Same error. ❌ tRPC failed on : 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 |
I had the same issue; replaced Theo's middleware.ts file with this snippet based on the previous suggestions: import { withClerkMiddleware } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";
export default withClerkMiddleware(() => {
console.log("middleware running...");
return NextResponse.next();
});
export const config = {
matcher: ["/(.*?trpc.*?|(?!static|.*\\..*|_next|favicon.ico).*)", "/"],
}; I also deleted the node modules folder and ran npm install. Problem solved! Thanks everyone 🥂 |
This worked for me, but couldn't make it work using the new API, since withClerkMiddleware is deprecated. Has anyone been able to? |
When follwing the youtube tutorial, I get the following message as soon as I add the
getAuth
in thetrcp.ts
:I think I did everything like mentioned, also I compared the middleware.ts and the trcp.ts with the ones in this repository. Do you/any of you know what could have gone wrong here?
Here's the link to my repo: https://github.com/27leaves/chirp/
Thank you!
The text was updated successfully, but these errors were encountered: