dani
dani
TTCTheo's Typesafe Cult
Created by dani on 10/8/2024 in #questions
Error 500 when using NextJS
No description
5 replies
TTCTheo's Typesafe Cult
Created by dani on 10/8/2024 in #questions
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;
5 replies