mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
refactor: impl part of grpcweb
This commit is contained in:
15
web/src/grpcweb.ts
Normal file
15
web/src/grpcweb.ts
Normal file
@ -0,0 +1,15 @@
|
||||
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);
|
Reference in New Issue
Block a user