uploadthing icon indicating copy to clipboard operation
uploadthing copied to clipboard

[bug]: Blocked by CORS policy. No 'Access-Control-Allow-Origin' header is present on the requested resource.

Open codesbyhusnain opened this issue 1 year ago β€’ 31 comments

Provide environment information

System:
    OS: macOS 15.0
    CPU: (8) arm64 Apple M2
    Memory: 79.98 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
    npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
    bun: 1.1.24 - ~/.bun/bin/bun
  Browsers:
    Chrome: 128.0.6613.138
    Safari: 18.0
  npmPackages:
    @uploadthing/react: ^7.0.2 => 7.0.2 
    typescript: ^5 => 5.6.2 
    uploadthing: ^7.0.2 => 7.0.2

Describe the bug

I am using Next.js App router in my project and uploadthing to handle my image and video upload. I followed the documentation exactly as on the website.

This is my api/uploadthing/core.ts:

import { auth } from "@clerk/nextjs/server";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";

const f = createUploadthing();

const handleAuth = () => {
  // Authentication logic
  const { userId } = auth();
  if (!userId) throw new UploadThingError("Unauthorized");
  return { userId };
};

// FileRouter for your app, can contain multiple FileRoutes
export const ourFileRouter = {
  courseImage: f({ image: { maxFileSize: "16MB", maxFileCount: 1 } })
    .onUploadComplete(() => { console.log("Complete")}),

  courseAttachment: f(["text", "image", "video", "audio", "pdf"])
    .middleware(() => handleAuth())
    .onUploadComplete(() => {}),

  chapterVideo: f({ video: { maxFileCount: 1, maxFileSize: "512GB" } })
    .middleware(() => handleAuth())
    .onUploadComplete(() => {}),
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;

This is my route.ts: 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: { ... },
});

This is my lib/uploadthing.ts:

import {
  generateUploadButton,
  generateUploadDropzone,
} from "@uploadthing/react";

import type { OurFileRouter } from "@/app/api/uploadthing/core";

export const UploadButton = generateUploadButton<OurFileRouter>();
export const UploadDropzone = generateUploadDropzone<OurFileRouter>();

I am getting this error when I try to upload an image Screenshot 2024-09-19 at 5 50 08β€―AM

Link to reproduction

https://stackblitz.com/github/pingdotgg/uploadthing/tree/main/examples/minimal-appdir?file=README.md

To reproduce

Follow the steps I mentioned in my bug to reproduce this issue.

Additional information

No response

πŸ‘¨β€πŸ‘§β€πŸ‘¦ Contributing

  • [x] πŸ™‹β€β™‚οΈ Yes, I'd be down to file a PR fixing this bug!

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

codesbyhusnain avatar Sep 19 '24 00:09 codesbyhusnain

hey sorry for this. we're aware and working on nailing down the issue.

if you don't mind me asking, do you see this for all uploads, or just some? Any correlation in file upload size to when it errors? Our current working theory is that this is more likely to happen for very small files

juliusmarminge avatar Sep 19 '24 10:09 juliusmarminge

I tried uploading 2 different files. 1 was 5 MB and the other was 2 KB. I ran into this error on both occasions. I don't think it has anything to do with filesize. Maybe CORS settings on your receiving end.

codesbyhusnain avatar Sep 19 '24 14:09 codesbyhusnain

can you provide the file keys for keys that fails?

fyi, the cors error is a "false"/inaccurate error of what's happening, you should not hit a 504 in the first place

juliusmarminge avatar Sep 19 '24 14:09 juliusmarminge

Hey @codesbyhusnain, I believe a fix has been deployed to our staging infra.

If you would like to help us confirm before shipping to prod, reach out to me on discord and I'll provide you with a token you can test with.

If not, no worries. I can ping here when the fix has been promoted to production

juliusmarminge avatar Sep 19 '24 15:09 juliusmarminge

running into the same issue. I'll wait until the fix propagates to all servers 🀞

mehrdadrafiee avatar Sep 19 '24 20:09 mehrdadrafiee

is this fixed? I'm able to upload (I see the uploaded file in my uploadthing dashboard) but I still get this error message.

mehrdadrafiee avatar Sep 20 '24 18:09 mehrdadrafiee

Just promoted the fix to production deployments.

Please let me know if the issue persists after giving it a go

juliusmarminge avatar Sep 20 '24 18:09 juliusmarminge

@juliusmarminge thanks! looks like the CORS error is gone now, however, I'm getting a 404 error now and am not able to upload.

GET http://localhost:3000/api/uploadthing 404 (Not Found)
// /api/uploadthing/core.ts

import { currentUser } from "@clerk/nextjs/server";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";

const f = createUploadthing();

const getUser = async () => await currentUser();

// FileRouter for your app, can contain multiple FileRoutes
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 }) => {
      // This code runs on your server before upload
      const user = await getUser();

      // If you throw, the user will not be able to upload
      if (!user) throw new UploadThingError("Unauthorized");

      // Whatever is returned here is accessible in onUploadComplete as `metadata`
      return { userId: user.id };
    })
    .onUploadComplete(async ({ metadata, file }) => {
      // This code RUNS ON YOUR SERVER after upload
      console.log("Upload complete for userId:", metadata.userId);

      console.log("file url", file.url);

      // !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback
      return { uploadedBy: metadata.userId };
    }),
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
// /api/uploadthing/route.ts

import { createRouteHandler } from "uploadthing/next";

import { ourFileRouter } from "./core";

export const { GET, POST } = createRouteHandler({ router: ourFileRouter });

I followed the documentation. anything I'm missing here?

mehrdadrafiee avatar Sep 20 '24 19:09 mehrdadrafiee

maybe you're running some other server on port 3000?

juliusmarminge avatar Sep 20 '24 19:09 juliusmarminge

killed all processes running on port 3000 and re-ran the app but still getting the 404 error:

button-client-Chdyu4qo.js:115 
        
GET http://localhost:3000/api/uploadthing 404 (Not Found)

running the app on a different port is not helping either πŸ€·β€β™‚οΈ

mehrdadrafiee avatar Sep 20 '24 20:09 mehrdadrafiee

I mean we haven't changed anything on the package side so if that part worked before it's something on your machine πŸ€·β€β™‚οΈ restart system maybe?

juliusmarminge avatar Sep 20 '24 20:09 juliusmarminge

Hi, I just encounteted the same issue today

Access to XMLHttpRequest at 'https://sea1.ingest.uploadthing.com/sREXOvoL8YcFXk9s7GrwE0iblNId7JnGZtx8M32jehg6RpLz?expires=1726914551940&x-ut-identifier=wau16cs4n9&x-ut-file-name=Screenshot%25202024-08-25%2520at%252010.42.45%25E2%2580%25AFPM.png&x-ut-file-size=469011&x-ut-file-type=image%252Fpng&x-ut-slug=imageUploader&x-ut-content-disposition=inline&signature=hmac-sha256%3D8d6467592330d4777f01f018cf99d6fb2992e39feed08039946eee53cb5929f3' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.Understand this error

Uploads are failing on the client side but the uploaded fiels are in my UT dashboard

onUploadError() is being triggered while onClientUploadComplete() is not

butadpj avatar Sep 21 '24 09:09 butadpj

Hi, I just encounteted the same issue today

Access to XMLHttpRequest at 'https://sea1.ingest.uploadthing.com/sREXOvoL8YcFXk9s7GrwE0iblNId7JnGZtx8M32jehg6RpLz?expires=1726914551940&x-ut-identifier=wau16cs4n9&x-ut-file-name=Screenshot%25202024-08-25%2520at%252010.42.45%25E2%2580%25AFPM.png&x-ut-file-size=469011&x-ut-file-type=image%252Fpng&x-ut-slug=imageUploader&x-ut-content-disposition=inline&signature=hmac-sha256%3D8d6467592330d4777f01f018cf99d6fb2992e39feed08039946eee53cb5929f3' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.Understand this error

Uploads are failing on the client side but the uploaded fiels are in my UT dashboard

onUploadError() is being triggered while onClientUploadComplete() is not

Same problemπŸ’―! It's just keep loading after a successful upload, but instead of getting the right response, I got the same error as yours above!!

codezeloss avatar Sep 21 '24 09:09 codezeloss

All my angular fire applications that uses Google federation for authentication now fail with chrome:

Access to fetch at 'https://securetoken.googleapis.com/v1/token?key=xxx' from origin 'http://localhost:4400' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

they no no matter whether they are localhost or real production URL. Works fine on Chrome yesterday. Now fails with Chrome 128.0.6613.138 and 129.0.6668.59. Still works fine on Edge.

And I cannot access Feedly anymore, because I login my account using Google federation. I guess everything that rides Login using Google is now dead on Chrome.

alexfung888 avatar Sep 21 '24 16:09 alexfung888

Oh god. I just realized I have this condition in my clerkMiddleware() that protects all routes except to routes in my isPublicRoute route matcher. So, if you're using Clerk on your auth, make sure you don't protect the entire "/api/uploadthing" as mentioned in the docs

image

butadpj avatar Sep 22 '24 01:09 butadpj

So, this issue was happening for me because my callback url was not set correctly. Setting UPLOADTHING_CALLBACK_URL environment variable to the route handler's path fixed it for me!

AkshatKejriwal avatar Sep 22 '24 23:09 AkshatKejriwal

image image

Still facing the same issue. Using uploadthing latest version. I'm not using typescript on my project.

mobashirul-alam avatar Sep 23 '24 03:09 mobashirul-alam

For anyone encountering this, can you please provide

  • enable debug logs (UPLOADTHING_LOG_LEVEL=Debug or set config variable) and provide those (these are server logs, not from the browser). MAKE SURE TO REDACT x-uploadthing-api-key HEADER VALUE BEFORE SENDING
  • if repo is open source, link it.

Thanks! We're also still looking for beta testers that can help us confirm if our fixes are working or not. Reach out on discord if you wanna help out.

Sorry for the inconvenience, we're aware and working on a fix but none of us are able to reproduce it from our machines which makes it difficult to say for when when a fix is working or not

juliusmarminge avatar Sep 23 '24 07:09 juliusmarminge

I upgraded Chrome to 129.0.6668.71 and the federation problem disappeared

alexfung888 avatar Sep 25 '24 00:09 alexfung888

Going back to the legacy version from "[email protected] @uploadthing/[email protected]" to "[email protected] @uploadthing/[email protected]", and right now is working as expected πŸ”₯πŸ’―

codezeloss avatar Sep 26 '24 13:09 codezeloss

Going back to the legacy version from "[email protected] @uploadthing/[email protected]" to "[email protected] @uploadthing/[email protected]", and right now is working as expected πŸ”₯πŸ’―

Hi @codezeloss , if that's the case, maybe you forgot to update your API Key that is appropriate for the latest version to work? image

butadpj avatar Sep 26 '24 13:09 butadpj

Going back to the legacy version from "[email protected] @uploadthing/[email protected]" to "[email protected] @uploadthing/[email protected]", and right now is working as expected πŸ”₯πŸ’―

v6 and v7 use entirely different infrastructure, so that doesn't help us narrow down the issue. Please see https://github.com/pingdotgg/uploadthing/issues/962#issuecomment-2367397687 for how to provide debug information

juliusmarminge avatar Sep 26 '24 14:09 juliusmarminge

Going back to the legacy version from "[email protected] @uploadthing/[email protected]" to "[email protected] @uploadthing/[email protected]", and right now is working as expected πŸ”₯πŸ’―

Hi @codezeloss , if that's the case, maybe you forgot to update your API Key that is appropriate for the latest version to work? image

Hi @butadpj! Yes I did, but always facing the same problem as @mobashirul-alam faced above...

codezeloss avatar Sep 26 '24 21:09 codezeloss

image image

Still facing the same issue. Using uploadthing latest version. I'm not using typescript on my project.

I am facing the same issue. Although my files are in my uploadthing dashboard. Here is a verbose debug log


 βœ“ Compiled /api/uploadthing in 297ms (1143 modules)
01:21:45.408 DEBUG handleUploadAction Handling upload request
ᐉ { "json": {"files":[{"name":"50803-461709594_tiny.mp4","size":1945697,"type":"video/mp4","lastModified":1727547435383}]} }
01:21:45.410 DEBUG handleUploadAction Parsing user input
01:21:45.411 DEBUG handleUploadAction Input parsed successfully
ᐉ { "input": undefined }
01:21:45.411 DEBUG handleUploadAction -> runRouteMiddleware Running middleware
01:21:46.144 DEBUG handleUploadAction Parsing route config
ᐉ { "routerConfig": {"video":{"maxFileSize":"64MB"},"audio":{"maxFileSize":"64MB"}} }
01:21:46.145 DEBUG handleUploadAction Route config parsed successfully
ᐉ { "routeConfig": {"video":{"maxFileSize":"64MB","maxFileCount":1,"minFileCount":1,"contentDisposition":"inline"},"audio":{"maxFileSize":"64MB","maxFileCount":1,"minFileCount":1,"contentDisposition":"inline"}} }
01:21:46.146 DEBUG handleUploadAction Validating files meet the config requirements
ᐉ { "files": [{"name":"50803-461709594_tiny.mp4","size":1945697,"type":"video/mp4","lastModified":1727547435383}] }
01:21:46.148 DEBUG handleUploadAction Files validated.
01:21:46.154 DEBUG handleUploadAction Generating presigned URLs
ᐉ { "fileUploadRequests": [{"name":"50803-461709594_tiny.mp4","size":1945697,"type":"video/mp4","lastModified":1727551306144,"contentDisposition":"inline"}], "ingestUrl": https://sea1.ingest.uploadthing.com }
01:21:46.175 INFO  handleUploadAction Sending presigned URLs to client
ᐉ { "presignedUrls": [{"url":"https://sea1.ingest.uploadthing.com/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf?expires=1727554906163&x-ut-identifier=soorbxazjo&x-ut-file-name=50803-461709594_tiny.mp4&x-ut-file-size=1945697&x-ut-file-type=video%252Fmp4&x-ut-slug=videoOrAudioUploader&x-ut-content-disposition=inline&signature=hmac-sha256%3D404ec82129898b8f7b4eaccd6bbc3a0902bee310178519fcd8fe282f6fcfb40f","key":"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf","name":"50803-461709594_tiny.mp4","customId":null}] }
01:21:46.176 DEBUG Running fiber as daemon
ᐉ { "handleDaemon": void }
01:21:46.178 DEBUG Sending response
ᐉ { "body": [{"url":"https://sea1.ingest.uploadthing.com/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf?expires=1727554906163&x-ut-identifier=soorbxazjo&x-ut-file-name=50803-461709594_tiny.mp4&x-ut-file-size=1945697&x-ut-file-type=video%252Fmp4&x-ut-slug=videoOrAudioUploader&x-ut-content-disposition=inline&signature=hmac-sha256%3D404ec82129898b8f7b4eaccd6bbc3a0902bee310178519fcd8fe282f6fcfb40f","key":"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf","name":"50803-461709594_tiny.mp4","customId":null}] }
 POST /api/uploadthing?actionType=upload&slug=videoOrAudioUploader 200 in 1698ms
01:22:08.396 DEBUG handleUploadAction -> handleJsonLineStream Registerred metadata
ᐉ { "response": {"_id":"@effect/platform/HttpClientResponse","request":{"_id":"@effect/platform/HttpClientRequest","method":"POST","url":"https://sea1.ingest.uploadthing.com/route-metadata","urlParams":[],"hash":{"_id":"Option","_tag":"None"},"headers":{"x-uploadthing-api-key":"REDACTED","x-uploadthing-version":"7.0.2","x-uploadthing-be-adapter":"nextjs-app","x-uploadthing-fe-package":"@uploadthing/react","content-type":"application/json","content-length":"251","b3":"68cd610a0fbfceff09b1adab6c2bf533-f48f5fd636399a65-1-c0618731497ab4de","traceparent":"00-68cd610a0fbfceff09b1adab6c2bf533-f48f5fd636399a65-01"},"body":{"_id":"@effect/platform/HttpBody","_tag":"Uint8Array","body":"{\"fileKeys\":[\"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\"],\"metadata\":{\"userId\":\"user_2mUQP3Zs9gdHQAxrOfKYJuEdrHb\"},\"isDev\":true,\"callbackUrl\":\"http://localhost:3000/api/uploadthing/\",\"callbackSlug\":\"videoOrAudioUploader\",\"awaitServerData\":true}","contentType":"application/json","contentLength":251}},"status":200,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"x-ut-range-start","connection":"keep-alive","date":"Sat, 28 Sep 2024 19:22:08 GMT","transfer-encoding":"chunked"},"remoteAddress":{"_id":"Option","_tag":"None"}} }
01:22:08.404 DEBUG handleUploadAction -> handleJsonLineStream Received chunks
ᐉ { "buf": , "parsedChunks": [{"payload":"{\"status\":\"uploaded\",\"metadata\":{\"userId\":\"user_2mUQP3Zs9gdHQAxrOfKYJuEdrHb\"},\"file\":{\"url\":\"https://utfs.io/f/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"appUrl\":\"https://utfs.io/a/soorbxazjo/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"name\":\"50803-461709594_tiny.mp4\",\"key\":\"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"size\":1945697,\"type\":\"video/mp4\",\"customId\":null}}","signature":"hmac-sha256=a14c462cb3ae77558eee4cbfa961c5f5bd0411776ce036ae0051370531d76ca5","hook":"callback"}], "chunk": {"payload":"{\"status\":\"uploaded\",\"metadata\":{\"userId\":\"user_2mUQP3Zs9gdHQAxrOfKYJuEdrHb\"},\"file\":{\"url\":\"https://utfs.io/f/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"appUrl\":\"https://utfs.io/a/soorbxazjo/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"name\":\"50803-461709594_tiny.mp4\",\"key\":\"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"size\":1945697,\"type\":\"video/mp4\",\"customId\":null}}","signature":"hmac-sha256=a14c462cb3ae77558eee4cbfa961c5f5bd0411776ce036ae0051370531d76ca5","hook":"callback"}
 }
 β—‹ Compiling /_not-found ...
 βœ“ Compiled /_not-found in 702ms (1531 modules)

shouravrahman avatar Sep 28 '24 19:09 shouravrahman

Oh god. I just realized I have this condition in my clerkMiddleware() that protects all routes except to routes in my isPublicRoute route matcher. So, if you're using Clerk on your auth, make sure you don't protect the entire "/api/uploadthing" as mentioned in the docs

image

Adding '/api/uploadthing(.*)' solved it for me. Been 2 days before i found this thread. Thanks.

davorrapic1 avatar Sep 29 '24 14:09 davorrapic1

Hi Everyone, I am too facing the same issue. I am not using any UI component for uploading the file but rather generating a pdf on the fly and uploading it using below code.

import { genUploader } from "uploadthing/client";
import type { OurFileRouter } from "@/app/api/uploadthing/core";
export const { uploadFiles } = genUploader<OurFileRouter>({
  package: "uploadthing/client",
  url: "/api/uploadthing",
});
 const response = await uploadFiles("pdfUploader", {
 files: [file],
 });

It's uploading the file but giving error. Logs : Sending presigned URLs to client { "presignedUrls": [{"url":""}] POST /api/uploadthing?actionType=upload&slug=pdfUploader 200 in 7441ms GET /sign-in 200 in 280ms

jagdishpadeliya avatar Oct 01 '24 09:10 jagdishpadeliya

t's uploading the file but giving error. Logs : Sending presigned URLs to client { "presignedUrls": [{"url":""}] POST /api/uploadthing?actionType=upload&slug=pdfUploader 200 in 7441ms GET /sign-in 200 in 280ms

looks like you tried uploading 0 files? We should block on this and require min 1 file before attempting an upload

juliusmarminge avatar Oct 01 '24 09:10 juliusmarminge

image image Still facing the same issue. Using uploadthing latest version. I'm not using typescript on my project.

I am facing the same issue. Although my files are in my uploadthing dashboard. Here is a verbose debug log


 βœ“ Compiled /api/uploadthing in 297ms (1143 modules)
01:21:45.408 DEBUG handleUploadAction Handling upload request
ᐉ { "json": {"files":[{"name":"50803-461709594_tiny.mp4","size":1945697,"type":"video/mp4","lastModified":1727547435383}]} }
01:21:45.410 DEBUG handleUploadAction Parsing user input
01:21:45.411 DEBUG handleUploadAction Input parsed successfully
ᐉ { "input": undefined }
01:21:45.411 DEBUG handleUploadAction -> runRouteMiddleware Running middleware
01:21:46.144 DEBUG handleUploadAction Parsing route config
ᐉ { "routerConfig": {"video":{"maxFileSize":"64MB"},"audio":{"maxFileSize":"64MB"}} }
01:21:46.145 DEBUG handleUploadAction Route config parsed successfully
ᐉ { "routeConfig": {"video":{"maxFileSize":"64MB","maxFileCount":1,"minFileCount":1,"contentDisposition":"inline"},"audio":{"maxFileSize":"64MB","maxFileCount":1,"minFileCount":1,"contentDisposition":"inline"}} }
01:21:46.146 DEBUG handleUploadAction Validating files meet the config requirements
ᐉ { "files": [{"name":"50803-461709594_tiny.mp4","size":1945697,"type":"video/mp4","lastModified":1727547435383}] }
01:21:46.148 DEBUG handleUploadAction Files validated.
01:21:46.154 DEBUG handleUploadAction Generating presigned URLs
ᐉ { "fileUploadRequests": [{"name":"50803-461709594_tiny.mp4","size":1945697,"type":"video/mp4","lastModified":1727551306144,"contentDisposition":"inline"}], "ingestUrl": https://sea1.ingest.uploadthing.com }
01:21:46.175 INFO  handleUploadAction Sending presigned URLs to client
ᐉ { "presignedUrls": [{"url":"https://sea1.ingest.uploadthing.com/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf?expires=1727554906163&x-ut-identifier=soorbxazjo&x-ut-file-name=50803-461709594_tiny.mp4&x-ut-file-size=1945697&x-ut-file-type=video%252Fmp4&x-ut-slug=videoOrAudioUploader&x-ut-content-disposition=inline&signature=hmac-sha256%3D404ec82129898b8f7b4eaccd6bbc3a0902bee310178519fcd8fe282f6fcfb40f","key":"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf","name":"50803-461709594_tiny.mp4","customId":null}] }
01:21:46.176 DEBUG Running fiber as daemon
ᐉ { "handleDaemon": void }
01:21:46.178 DEBUG Sending response
ᐉ { "body": [{"url":"https://sea1.ingest.uploadthing.com/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf?expires=1727554906163&x-ut-identifier=soorbxazjo&x-ut-file-name=50803-461709594_tiny.mp4&x-ut-file-size=1945697&x-ut-file-type=video%252Fmp4&x-ut-slug=videoOrAudioUploader&x-ut-content-disposition=inline&signature=hmac-sha256%3D404ec82129898b8f7b4eaccd6bbc3a0902bee310178519fcd8fe282f6fcfb40f","key":"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf","name":"50803-461709594_tiny.mp4","customId":null}] }
 POST /api/uploadthing?actionType=upload&slug=videoOrAudioUploader 200 in 1698ms
01:22:08.396 DEBUG handleUploadAction -> handleJsonLineStream Registerred metadata
ᐉ { "response": {"_id":"@effect/platform/HttpClientResponse","request":{"_id":"@effect/platform/HttpClientRequest","method":"POST","url":"https://sea1.ingest.uploadthing.com/route-metadata","urlParams":[],"hash":{"_id":"Option","_tag":"None"},"headers":{"x-uploadthing-api-key":"REDACTED","x-uploadthing-version":"7.0.2","x-uploadthing-be-adapter":"nextjs-app","x-uploadthing-fe-package":"@uploadthing/react","content-type":"application/json","content-length":"251","b3":"68cd610a0fbfceff09b1adab6c2bf533-f48f5fd636399a65-1-c0618731497ab4de","traceparent":"00-68cd610a0fbfceff09b1adab6c2bf533-f48f5fd636399a65-01"},"body":{"_id":"@effect/platform/HttpBody","_tag":"Uint8Array","body":"{\"fileKeys\":[\"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\"],\"metadata\":{\"userId\":\"user_2mUQP3Zs9gdHQAxrOfKYJuEdrHb\"},\"isDev\":true,\"callbackUrl\":\"http://localhost:3000/api/uploadthing/\",\"callbackSlug\":\"videoOrAudioUploader\",\"awaitServerData\":true}","contentType":"application/json","contentLength":251}},"status":200,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"x-ut-range-start","connection":"keep-alive","date":"Sat, 28 Sep 2024 19:22:08 GMT","transfer-encoding":"chunked"},"remoteAddress":{"_id":"Option","_tag":"None"}} }
01:22:08.404 DEBUG handleUploadAction -> handleJsonLineStream Received chunks
ᐉ { "buf": , "parsedChunks": [{"payload":"{\"status\":\"uploaded\",\"metadata\":{\"userId\":\"user_2mUQP3Zs9gdHQAxrOfKYJuEdrHb\"},\"file\":{\"url\":\"https://utfs.io/f/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"appUrl\":\"https://utfs.io/a/soorbxazjo/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"name\":\"50803-461709594_tiny.mp4\",\"key\":\"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"size\":1945697,\"type\":\"video/mp4\",\"customId\":null}}","signature":"hmac-sha256=a14c462cb3ae77558eee4cbfa961c5f5bd0411776ce036ae0051370531d76ca5","hook":"callback"}], "chunk": {"payload":"{\"status\":\"uploaded\",\"metadata\":{\"userId\":\"user_2mUQP3Zs9gdHQAxrOfKYJuEdrHb\"},\"file\":{\"url\":\"https://utfs.io/f/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"appUrl\":\"https://utfs.io/a/soorbxazjo/kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"name\":\"50803-461709594_tiny.mp4\",\"key\":\"kx4ZYZbacSdXCnNgmh5JNmJGgHaqBj06XUroxRitLysehkKf\",\"size\":1945697,\"type\":\"video/mp4\",\"customId\":null}}","signature":"hmac-sha256=a14c462cb3ae77558eee4cbfa961c5f5bd0411776ce036ae0051370531d76ca5","hook":"callback"}
 }
 β—‹ Compiling /_not-found ...
 βœ“ Compiled /_not-found in 702ms (1531 modules)

looks like everything that should happen on the server happened, except for acknowledgement about the callback response. Verify that your /api/uploadthing route is not blocking requests from e.g. Next.js middleware

juliusmarminge avatar Oct 01 '24 09:10 juliusmarminge

@juliusmarminge Here's the log

14:57:18.029 DEBUG handleUploadAction Handling upload                                                    request
ᐉ { "json": {"files":[{"name":"Invoice-VIP/2024-25/0012.pdf","size":63488,"type":"application/pdf","lastModified":1727774837703}]} }
14:57:18.032 DEBUG handleUploadAction Parsing user input
14:57:18.033 DEBUG handleUploadAction Input parsed successfully
ᐉ { "input": undefined }
14:57:18.034 DEBUG handleUploadAction -> runRouteMiddleware Running middleware
id cm023vv8a00009znwd8uy8r3x
14:57:18.312 DEBUG handleUploadAction Parsing route config
ᐉ { "routerConfig": {"pdf":{"maxFileSize":"8MB"}} }   
14:57:18.313 DEBUG handleUploadAction Route config parsed successfully
ᐉ { "routeConfig": {"pdf":{"maxFileSize":"8MB","maxFileCount":1,"minFileCount":1,"contentDisposition":"inline"}} }
14:57:18.314 DEBUG handleUploadAction Validating files meet the config requirements
ᐉ { "files": [{"name":"Invoice-VIP/2024-25/0012.pdf","size":63488,"type":"application/pdf","lastModified":1727774837703}] }
14:57:18.317 DEBUG handleUploadAction Files validated.
14:57:18.322 DEBUG handleUploadAction Generating presigned URLs
ᐉ { "fileUploadRequests": [{"name":"Invoice-VIP/2024-25/0012.pdf","size":63488,"type":"application/pdf","lastModified":1727774838311,"contentDisposition":"inline"}], "ingestUrl": https://sea1.ingest.uploadthing.com }
14:57:18.333 INFO  handleUploadAction Sending presigned URLs to client
ᐉ { "presignedUrls": [{"url":"https://sea1.ingest.uploadthing.com/kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog?expires=1727778438328&x-ut-identifier=443rqxfxn1&x-ut-file-name=Invoice-VIP%252F2024-25%252F0012.pdf&x-ut-file-size=63488&x-ut-file-type=application%252Fpdf&x-ut-slug=pdfUploader&x-ut-content-disposition=inline&signature=hmac-sha256%3D295edacd71b184d3348acce9b70de3b01917f30e73fbd76f6f9dea37731bacb9","key":"kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog","name":"Invoice-VIP/2024-25/0012.pdf","customId":null}] }
14:57:18.335 DEBUG Running fiber as daemon
ᐉ { "handleDaemon": void }
14:57:18.336 DEBUG Sending response
ᐉ { "body": [{"url":"https://sea1.ingest.uploadthing.com/kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog?expires=1727778438328&x-ut-identifier=443rqxfxn1&x-ut-file-name=Invoice-VIP%252F2024-25%252F0012.pdf&x-ut-file-size=63488&x-ut-file-type=application%252Fpdf&x-ut-slug=pdfUploader&x-ut-content-disposition=inline&signature=hmac-sha256%3D295edacd71b184d3348acce9b70de3b01917f30e73fbd76f6f9dea37731bacb9","key":"kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog","name":"Invoice-VIP/2024-25/0012.pdf","customId":null}] }
 POST /api/uploadthing?actionType=upload&slug=pdfUploader 200 in 616ms
14:57:19.830 DEBUG handleUploadAction -> handleJsonLineStream Registerred metadata
ᐉ { "response": {"_id":"@effect/platform/HttpClientResponse","request":{"_id":"@effect/platform/HttpClientRequest","method":"POST","url":"https://sea1.ingest.uploadthing.com/route-metadata","urlParams":[],"hash":{"_id":"Option","_tag":"None"},"headers":{"x-uploadthing-api-key":"REDACTED","x-uploadthing-version":"7.0.2","x-uploadthing-be-adapter":"nextjs-app","x-uploadthing-fe-package":"undefined","content-type":"application/json","content-length":"234","b3":"cb813507dedf0252e486a4981e4db9d1-3ad90b4949b24b3c-1-0c95a24f1e73ce7d","traceparent":"00-cb813507dedf0252e486a4981e4db9d1-3ad90b4949b24b3c-01"},"body":{"_id":"@effect/platform/HttpBody","_tag":"Uint8Array","body":"{\"fileKeys\":[\"kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog\"],\"metadata\":{\"userId\":\"cm023vv8a00009znwd8uy8r3x\"},\"isDev\":true,\"callbackUrl\":\"http://localhost:3000/api/uploadthing\",\"callbackSlug\":\"pdfUploader\",\"awaitServerData\":true}","contentType":"application/json","contentLength":234}},"status":200,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"x-ut-range-start","connection":"keep-alive","date":"Tue, 01 Oct 2024 09:27:20 GMT","transfer-encoding":"chunked"},"remoteAddress":{"_id":"Option","_tag":"None"}} }
14:57:19.839 DEBUG handleUploadAction -> handleJsonLineStream Received chunks
ᐉ { "buf": , "parsedChunks": [{"payload":"{\"status\":\"uploaded\",\"metadata\":{\"userId\":\"cm023vv8a00009znwd8uy8r3x\"},\"file\":{\"url\":\"https://utfs.io/f/kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog\",\"appUrl\":\"https://utfs.io/a/443rqxfxn1/kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog\",\"name\":\"Invoice-VIP/2024-25/0012.pdf\",\"key\":\"kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog\",\"size\":63488,\"type\":\"application/pdf\",\"customId\":null}}","signature":"hmac-sha256=d810c822ac4a4bf4674f70d3a69167f7ea2f463ef3461c23e168086c2ae43a2c","hook":"callback"}], "chunk": {"payload":"{\"status\":\"uploaded\",\"metadata\":{\"userId\":\"cm023vv8a00009znwd8uy8r3x\"},\"file\":{\"url\":\"https://utfs.io/f/kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog\",\"appUrl\":\"https://utfs.io/a/443rqxfxn1/kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog\",\"name\":\"Invoice-VIP/2024-25/0012.pdf\",\"key\":\"kjUnieWQdAm200muswoVOiaKrRX8x6ectkJGb739MjWfATog\",\"size\":63488,\"type\":\"application/pdf\",\"customId\":null}}","signature":"hmac-sha256=d810c822ac4a4bf4674f70d3a69167f7ea2f463ef3461c23e168086c2ae43a2c","hook":"callback"}
 }
 GET /sign-in 200 in 309ms
14:57:20.198 INFO  handleUploadAction -> handleJsonLineStream Successfully simulated 'callback' event

jagdishpadeliya avatar Oct 01 '24 09:10 jagdishpadeliya

@juliusmarminge issue was with the middleware. Thanks, it got fixed now.

jagdishpadeliya avatar Oct 01 '24 09:10 jagdishpadeliya