mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-06 21:22:36 +00:00
feat: impl grpcweb in frontend
This commit is contained in:
18
frontend/web/src/grpcweb.ts
Normal file
18
frontend/web/src/grpcweb.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { createChannel, createClientFactory, FetchTransport } from "nice-grpc-web";
|
||||
import { UserServiceDefinition } from "./types/proto/api/v2/user_service";
|
||||
import { WorkspaceSettingServiceDefinition } from "./types/proto/api/v2/workspace_setting_service";
|
||||
|
||||
const address = import.meta.env.MODE === "development" ? "http://localhost:8082" : window.location.origin;
|
||||
|
||||
const channel = createChannel(
|
||||
address,
|
||||
FetchTransport({
|
||||
credentials: "include",
|
||||
})
|
||||
);
|
||||
|
||||
const clientFactory = createClientFactory();
|
||||
|
||||
export const userServiceClient = clientFactory.create(UserServiceDefinition, channel);
|
||||
|
||||
export const workspaceSettingServiceClient = clientFactory.create(WorkspaceSettingServiceDefinition, channel);
|
Reference in New Issue
Block a user