edgestorejs/edgestore

Error when deploying to vercel.

Seeeev opened this issue · 2 comments

Seeeev commented

I am setting up a backend client based from the documentation https://edgestore.dev/docs/backend-client. But when i upload to vercel i faced this error message:

Failed to compile.

22:05:04.601 |  
22:05:04.602 | src/app/api/edgestore/[...edgestore]/route.ts
22:05:04.602 | Type error: Route "src/app/api/edgestore/[...edgestore]/route.ts" does not match the required types of a Next.js Route.
22:05:04.602 | "backendClient" is not a valid Route export field.
22:05:04.602 |  
22:05:04.726 | Error: Command "npm run build" exited with 1

edgestore/[...edgestore]/route.ts

import { initEdgeStore } from '@edgestore/server';
import { createEdgeStoreNextHandler } from '@edgestore/server/adapters/next/app';
import { initEdgeStoreClient } from '@edgestore/server/core';

const es = initEdgeStore.create();
 
const edgeStoreRouter = es.router({
  publicFiles: es.fileBucket(),
});
 
const handler = createEdgeStoreNextHandler({
  router: edgeStoreRouter,
});

export { handler as GET, handler as POST };
 

export type EdgeStoreRouter = typeof edgeStoreRouter;

export const backendClient = initEdgeStoreClient({
  router: edgeStoreRouter,
});

Hi @Seeeev!
Yes. Sorry about that.
For the build command to work on Next.js you need to move everything in the route.ts file into another file. And then import only what you need inside the route.ts file.

Here is another similar issue:

vercel/next.js#50870

Here is the thread in discord:

https://discord.com/channels/1060144459431559208/1190011588455977133/1190678493906882591

I'll work on updating the docs for this.

Seeeev commented

Thank you, made the changes and works out fine.