Service Resolution Errors When Integrating Effect Platform HTTP API with TanStack Start

"Service not found" errors when mounting Effect Platform HTTP API
to TanStack Start

I'm trying to mount an Effect Platform HTTP API to a TanStack Start
server route, but getting service resolution errors.

Setup:
- Effect Platform HTTP API with multiple endpoint groups
- TanStack Start with file-based routing
- Trying to mount the API at /api/effect/*

Error progression:
1. First error: Service not found: @effect/platform/HttpApi/Api
2. After fixes: Service not found: @effect/platform/HttpServer

Current code structure:

//server/api-live.ts
  export const ApiLive = HttpApiBuilder.api(MacrowaveApi).pipe(
    Layer.provide(apiHandlers),
    Layer.provide(AuthorizationLive),
    Layer.provide(AppLive),
  );


//routes/api/effect/$.ts (TanStack Start route)
  export const ServerRoute =
  createServerFileRoute("/api/effect/$").methods({
    GET: (request) => {
      const ServerLive = Layer.mergeAll(
        HttpApiBuilder.middlewareCors({...}),
        HttpApiBuilder.middlewareOpenApi(),
        HttpApiScalar.layer({...}),
      ).pipe(Layer.provide(ApiLive));

      const { handler: effectHandler } =
  HttpApiBuilder.toWebHandler(ServerLive);
      return effectHandler(newRequest);
    }
  });


What I've tried:
1. Removed commented RPC endpoint code
2. Various layer compositions
3. Adding/removing HttpServer.layerContext
4. Disabling Authorization middleware

Question:
How do I properly set up Effect Platform HTTP API with TanStack Start?
The HttpApiBuilder.toWebHandler seems to expect services that aren't
being provided correctly. Is there a specific pattern for integrating
with edge/serverless environments where we don't have a traditional HTTP
server?

Environment:
- @effect/platform: 0.87.1
- effect: 3.16.10
- @tanstack/start: latest
Was this page helpful?