You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
memos/web/src/grpcweb.ts

16 lines
507 B
TypeScript

import { createChannel, createClientFactory, FetchTransport } from "nice-grpc-web";
import { UserServiceDefinition } from "./types/proto-grpcweb/api/v2/user_service";
const address = import.meta.env.MODE === "development" ? "http://localhost:8081" : window.location.origin;
const channel = createChannel(
address,
FetchTransport({
credentials: "include",
})
);
const clientFactory = createClientFactory();
export const userServiceClient = clientFactory.create(UserServiceDefinition, channel);