reactjsnext.jsfile-upload

Next.js 15.3.2 + uploadthing: Uploaded Status but giving me an error


iam following Code with Antonio LMS course which is uploaded 2 years back, now when iam trying to approach with dealing with Uploadthing, iam getting error as follows when i tried to upload image using uploadthing:

payload: {"status":"uploaded","metadata":{"userId":"user_2wrRIa1P2wdMnAACnpxOc4hiDVn"},"origin":"https://sea1.ingest.uploadthing.com","file":{"url":"https://utfs.io/f/Dce7zkRgom6nUrk8duyOe91kDfyiNKaouW6hgZxSEFzpYJn8","appUrl":"https://utfs.io/a/8131c6rbjr/Dce7zkRgom6nUrk8duyOe91kDfyiNKaouW6hgZxSEFzpYJn8","ufsUrl":"https://8131c6rbjr.ufs.sh/f/Dce7zkRgom6nUrk8duyOe91kDfyiNKaouW6hgZxSEFzpYJn8","name":"454439273_468013692693485_7948648305382373860_n.jpg","key":"Dce7zkRgom6nUrk8duyOe91kDfyiNKaouW6hgZxSEFzpYJn8","size":83784,"type":"image/jpeg","customId":null,"fileHash":"88f51495e5d96931e60bd278d28f2cd6"}}
  fileKey: Dce7zkRgom6nUrk8duyOe91kDfyiNKaouW6hgZxSEFzpYJn8
  error: StatusCode: non 2xx status code (404 POST http://localhost:3000/api/uploadthing)
 POST /api/uploadthing?slug=courseImage 404 in 800ms

but iam having /api/uploadthing/route.ts as follows:

import { createRouteHandler } from "uploadthing/next";

import { ourFileRouter } from "./core";

// Export routes for Next App Router
export const { GET, POST } = createRouteHandler({
  router: ourFileRouter,

  // Apply an (optional) custom config:
  // config: { ... },
});

Solution

  • if you use authentification ,just check your middleware , you probably protected some pages , you should make the path '/api/uploadthing' public so uploadthing can use it