How to Implement a 302 Redirect with `effect-http` in TypeScript

Probably a dumb question, but couldn't find an example anywhere. How would I do the equivalent of something like
return new Response(null, {
  status: 302,
  headers: {
    Location: "/",
    "Set-Cookie": "cookie=abc"
  }
});

with effect-http? I tried doing something like
export const endpoint = Api.post("endpoint", "/endpoint").pipe(
  Api.setRequestBody(Body),
  Api.setResponseStatus(302),
  Api.setResponseHeaders(
    S.Struct({
      "set-cookie": S.String,
      location: S.String,
    }),
  ),
);

const endpointHandler = Handler.make(endpoint, ({ body }) =>
  Effect.gen(function* () {
    return {
      status: 302 as const,
      headers: {
        "set-cookie": "session=123; Path=/; HttpOnly",
        location: "/",
      },
    };
  }).pipe(Effect.withSpan("endpoint")),
);

but this gives TypeScript errors I do not understand
Was this page helpful?