EAS deploy error with uploadthing

I just copied the documentation but when I try to host, I get the below error
EAS Hosting is still in preview and subject to changes.
> Project export: server
✖ Failed to create deployment
Uncaught SyntaxError: Invalid or unexpected token
at _expo/functions/api/uploadthing+api.js:575:111
(10021)
Error: deploy command failed.
EAS Hosting is still in preview and subject to changes.
> Project export: server
✖ Failed to create deployment
Uncaught SyntaxError: Invalid or unexpected token
at _expo/functions/api/uploadthing+api.js:575:111
(10021)
Error: deploy command failed.
Here's my api route for reference
import { createUploadthing, UploadThingError, createRouteHandler } from "uploadthing/server";
import type { FileRouter } from "uploadthing/server";

const f = createUploadthing();

const auth = (req: Request) => ({ id: "fakeId" }); // Fake auth function

const uploadRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
imageUploader: f({
image: {
/**
* For full list of options and defaults, see the File Route API reference
* @see https://docs.uploadthing.com/file-routes#route-config
*/
maxFileSize: "4MB",
maxFileCount: 1,
},
})
.middleware(async ({ req }) => {
// This code runs on your server before upload
const user = await auth(req);

// 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(({ file, metadata }) => {
// This code RUNS ON YOUR SERVER after upload
console.log("Upload complete for userId:", metadata.userId);

console.log("file url", file.ufsUrl);
return { uploadedBy: metadata.userId };
}),
} satisfies FileRouter;
export type UploadRouter = typeof uploadRouter;

const handlers = createRouteHandler({
router: uploadRouter,
})
export { handlers as GET, handlers as POST }
import { createUploadthing, UploadThingError, createRouteHandler } from "uploadthing/server";
import type { FileRouter } from "uploadthing/server";

const f = createUploadthing();

const auth = (req: Request) => ({ id: "fakeId" }); // Fake auth function

const uploadRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
imageUploader: f({
image: {
/**
* For full list of options and defaults, see the File Route API reference
* @see https://docs.uploadthing.com/file-routes#route-config
*/
maxFileSize: "4MB",
maxFileCount: 1,
},
})
.middleware(async ({ req }) => {
// This code runs on your server before upload
const user = await auth(req);

// 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(({ file, metadata }) => {
// This code RUNS ON YOUR SERVER after upload
console.log("Upload complete for userId:", metadata.userId);

console.log("file url", file.ufsUrl);
return { uploadedBy: metadata.userId };
}),
} satisfies FileRouter;
export type UploadRouter = typeof uploadRouter;

const handlers = createRouteHandler({
router: uploadRouter,
})
export { handlers as GET, handlers as POST }
4 Replies
George
George3mo ago
Did you ever figure this out? Running into the same issue
xvxvxv1
xvxvxv1OP3mo ago
Nope I just switched to cloudinary hope they fix it tho what are u making btw?
George
George3mo ago
Its a part of startup i have where people can upload images to their portfolio. There's also a web app version which im using successfully using uploadthing for
xvxvxv1
xvxvxv1OP3mo ago
Oh cool who's like the target audience for it Also yeah i think it's just the expo version that doesnt wokr

Did you find this page helpful?