Files uploaded, but client and server never reach onUploadComplete

My files are uploading successfully to UploadThing (I can access them in dashboard), but the loading spinner goes indefinitely on client. onUploadComplete is not being triggered on server or client, and onUploadError is not being triggered clientside either. I had everything working fine the other day on setup, not sure what I did to fuck up. No errors in log on client or server. Any help is appreciated, thanks! next: 15.2.3 uploadthing: 7.6.0 component.tsx
<UploadButton
endpoint="inputSource"
onClientUploadComplete={() => {
refetch();
}}
onUploadError={(error: Error) => {
console.log('upload error', error);
}}
className="my-4"
/>
<UploadButton
endpoint="inputSource"
onClientUploadComplete={() => {
refetch();
}}
onUploadError={(error: Error) => {
console.log('upload error', error);
}}
className="my-4"
/>
route.ts
import { createRouteHandler } from 'uploadthing/next';
import { uploadRouter } from './core';

export const { GET, POST } = createRouteHandler({
router: uploadRouter,
});
import { createRouteHandler } from 'uploadthing/next';
import { uploadRouter } from './core';

export const { GET, POST } = createRouteHandler({
router: uploadRouter,
});
core.ts
export const uploadRouter = {
inputSource: f({
image: {
maxFileSize: '8MB',
maxFileCount: 1,
},
})
.middleware(async () => {
const { userId } = await auth();
if (!userId) throw new UploadThingError('Unauthorized');
return { userId };
})
.onUploadComplete(async ({ file }) => {
const caller = appRouter.createCaller(await createTRPCContext());
const { error } = await tryCatch(
caller.input.createInputSource({
url: file.ufsUrl,
type: 'IMAGE',
}),
);
if (error) throw new UploadThingError(error.message);
}),
} satisfies FileRouter;
export const uploadRouter = {
inputSource: f({
image: {
maxFileSize: '8MB',
maxFileCount: 1,
},
})
.middleware(async () => {
const { userId } = await auth();
if (!userId) throw new UploadThingError('Unauthorized');
return { userId };
})
.onUploadComplete(async ({ file }) => {
const caller = appRouter.createCaller(await createTRPCContext());
const { error } = await tryCatch(
caller.input.createInputSource({
url: file.ufsUrl,
type: 'IMAGE',
}),
);
if (error) throw new UploadThingError(error.message);
}),
} satisfies FileRouter;
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?