-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug]: onUploadComplete is never fired - Callback Failed - local development #1122
Comments
Is this related to the bug where when I try to upload an image, the POST req to the server gives an error code 500 |
If you hover over one of those items, does it give you any additional information?
Not sure what you are referring to here either, can you link a repro? |
Sorry to clarify - I meant if you hover over the "calback failed" - there should be a (i) icon
Seems like environment detection is not working correctly. can you try setting |
Yep! Setting this inside my |
this should already be fixed. try upgrading to 7.4.3 or later. re: config, all config can be set either through the config object or through env vars as explained here: https://docs.uploadthing.com/api-reference/server#config-parameters |
Following the video by Theo I run into some error which is persitent in prod import { auth } from "@clerk/nextjs/server";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";
import { db } from "~/server/db";
import { images } from "~/server/db/schema";
const f = createUploadthing();
export const ourFileRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
imageUploader: f({
image: {
maxFileSize: "4MB",
maxFileCount: 1,
},
})
// Set permissions and file types for this FileRoute
.middleware(async ({ req }) => {
try {
const user = await auth();
if (!user.userId) throw new UploadThingError("Unauthorized");
return { userId: user.userId };
} catch (error) {
throw new UploadThingError("Unauthorized");
}
})
.onUploadComplete(async ({ metadata, file }) => {
try {
console.log("onUploadComplete");
await db.insert(images).values({
name: file.name,
url: file.url,
userId: metadata.userId,
});
return { uploadedBy: metadata.userId };
} catch (error) {
console.log(error);
}
}),
} satisfies FileRouter;
export type OurFileRouter = typeof ourFileRouter; This is the import { createRouteHandler } from "uploadthing/next";
import { ourFileRouter } from "./core";
export const { GET, POST } = createRouteHandler({
router: ourFileRouter,
}); When I try to upload the POST request doesn't go through and gives a 500 status code in return |
Can you share a screenshot of the 500 error you are getting? Also enable debug logging on your route? |
For Fastify this caused me a few hours of headache only to realize I missed the fact that since v7 you have to pass in the dev flag when in dev like so:
|
the flag is and always have been inferred from |
This issue has been automatically marked as stale because it has not had any activity for 10 days. It will be closed in 5 days if no further activity occurs. |
Provide environment information
Describe the bug
I'm having the same or similar issue described here (#920), but with Next 15. File is uploaded successfully, with no errors in console.
However,
onUploadComplete
callback is never fired. My dashboard shows "Callback Failed" for all uploads.I have all api routes excluded from middleware. Here's some relevant code:
Link to reproduction
https://stackblitz.com/github/pingdotgg/uploadthing/tree/main/examples/minimal-appdir
To reproduce
// not applicable
Additional information
No response
👨👧👦 Contributing
Code of Conduct
The text was updated successfully, but these errors were encountered: