uploadthing error

I'm using the DANGEROUS__uploadFiles function and keep getting this error. I don't think I have done anything wrong, is this function deprecated?
No description
7 Replies
BILLY
BILLYOP15mo ago
No description
BILLY
BILLYOP15mo ago
No description
BILLY
BILLYOP15mo ago
No description
BILLY
BILLYOP15mo ago
import { createUploadthing, type FileRouter } from "uploadthing/next";
import {getSession} from "@/lib/session";

const f = createUploadthing();
export const ourFileRouter = {
imageUploader: f({ image: { maxFileSize: "4MB" } })
.middleware(async ({ req }) => {
let user = await getSession();
if (!user || !user.admin) throw new Error("Unauthorized");
return { userId: user.id };
})
.onUploadComplete(async ({ metadata, file }) => {
console.log("Upload complete for userId:", metadata.userId);
console.log("file url", file.url);
}),
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
import { createUploadthing, type FileRouter } from "uploadthing/next";
import {getSession} from "@/lib/session";

const f = createUploadthing();
export const ourFileRouter = {
imageUploader: f({ image: { maxFileSize: "4MB" } })
.middleware(async ({ req }) => {
let user = await getSession();
if (!user || !user.admin) throw new Error("Unauthorized");
return { userId: user.id };
})
.onUploadComplete(async ({ metadata, file }) => {
console.log("Upload complete for userId:", metadata.userId);
console.log("file url", file.url);
}),
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
core.ts
import { createNextRouteHandler } from "uploadthing/next";

import { ourFileRouter } from "./core";

export const { GET, POST } = createNextRouteHandler({
router: ourFileRouter,
});
import { createNextRouteHandler } from "uploadthing/next";

import { ourFileRouter } from "./core";

export const { GET, POST } = createNextRouteHandler({
router: ourFileRouter,
});
route.ts env has correct keys tried the latest version of uploadthing and ^5.3.3 as it worked previously in another project. tried the latest version of @uploadthing/react and ^5.3.0 as it worked previously in another project
julius
julius15mo ago
where are you using DANGEROUS_uploadFiles oh actually this error is probably cause you're using Node 16 right? fetch() is a bit stupid there and doesn't work all the time, we suggest using Node 18+, and as Node 16 is EOL I don't think we'll fix this error fyi, you'll get a big warning that will make this error easier to debug in the next version
BILLY
BILLYOP15mo ago
oof
No description
BILLY
BILLYOP15mo ago
work make me use 16 I forget... trying a different version now yeah, it works. thanks for pointing that out for me.
Want results from more Discord servers?
Add your server