Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
15 replies
Alex

Error when using clerk getAuth from UploadThing routes

Dear All, I'm having problem using clerk and uploadthing.
NextJs: version 13.4.4
React:18.2.0
Uploadthing:5.2.1
Typescript:5.1.6
And using the pages router of nextjs.
I tried to isolate the issue as such:
I have the uploadthing endpoint and a dummy enpoint using both clerck getAuth(req).
dummy.ts
import { getAuth } from '@clerk/nextjs/server'

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse,
) {
  const { userId } = getAuth(req)
  // Load any data your application needs for the API route
  return res.status(200).json(userId)
}
`
uploadthing.ts
import { createNextPageApiHandler } from 'uploadthing/next-legacy'
import {uploadRouter} from "../../server/upload-routes";

const handler = createNextPageApiHandler({
  router: uploadRouter,
})

export default handler
Screenshot_2023-07-25_at_11.03.26.png
Screenshot_2023-07-25_at_11.08.49.png
Was this page helpful?