Error 500 when using NextJS

When I try to upload an image, It returns error 500. I've triple checked and recoded the uploadthing part of my project and everything seems alright but it still won't upload. There is no "Failed" upload in the chart on the dashboard either. There are more scripts but they are all set as default from the docs. core.ts script:
import { auth } from "@clerk/nextjs/server";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";

const f = createUploadthing();

const handleAuth = () => {
const { userId} = auth();
if (!userId) throw new Error("Unauthorized");
return { userId: userId };
}

export const ourFileRouter = {
serverImage: f({ image: { maxFileSize: "4MB", maxFileCount: 1 } })
.middleware(() => handleAuth())
.onUploadComplete(() => {}),
messageFile: f(["image", "pdf", "video", "audio"])
.middleware(() => handleAuth())
.onUploadComplete(() => {})
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
import { auth } from "@clerk/nextjs/server";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";

const f = createUploadthing();

const handleAuth = () => {
const { userId} = auth();
if (!userId) throw new Error("Unauthorized");
return { userId: userId };
}

export const ourFileRouter = {
serverImage: f({ image: { maxFileSize: "4MB", maxFileCount: 1 } })
.middleware(() => handleAuth())
.onUploadComplete(() => {}),
messageFile: f(["image", "pdf", "video", "audio"])
.middleware(() => handleAuth())
.onUploadComplete(() => {})
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
No description
4 Replies
dani
daniOP6mo ago
When I try to upload an image, It returns error 500. I've triple checked and recoded the uploadthing part of my project and everything seems alright but it still won't upload. There is no "Failed" upload in the chart on the dashboard either. There are more scripts but they are all set as default from the docs. core.ts script:
import { auth } from "@clerk/nextjs/server";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";

const f = createUploadthing();

const handleAuth = () => {
const { userId} = auth();
if (!userId) throw new Error("Unauthorized");
return { userId: userId };
}

export const ourFileRouter = {
serverImage: f({ image: { maxFileSize: "4MB", maxFileCount: 1 } })
.middleware(() => handleAuth())
.onUploadComplete(() => {}),
messageFile: f(["image", "pdf", "video", "audio"])
.middleware(() => handleAuth())
.onUploadComplete(() => {})
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
import { auth } from "@clerk/nextjs/server";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";

const f = createUploadthing();

const handleAuth = () => {
const { userId} = auth();
if (!userId) throw new Error("Unauthorized");
return { userId: userId };
}

export const ourFileRouter = {
serverImage: f({ image: { maxFileSize: "4MB", maxFileCount: 1 } })
.middleware(() => handleAuth())
.onUploadComplete(() => {}),
messageFile: f(["image", "pdf", "video", "audio"])
.middleware(() => handleAuth())
.onUploadComplete(() => {})
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
dani
daniOP6mo ago
Update: Found this in chrome console
No description
Tserriednich
Tserriednich4mo ago
did you figure it out?
Kwanza
Kwanza4mo ago
Hi Dani. I seem to be having a similar issue. Did you end up figuring out the issue?

Did you find this page helpful?