diff --git a/tool/protoc-gen-mesh_ts_web/src/index.ts b/tool/protoc-gen-mesh_ts_web/src/index.ts index fcf3e660..bad7c65a 100644 --- a/tool/protoc-gen-mesh_ts_web/src/index.ts +++ b/tool/protoc-gen-mesh_ts_web/src/index.ts @@ -29,6 +29,7 @@ function generateConnectClientManually(schema: Schema, file: DescFile) { let content = ""; // Add file header + content += `// Code generated by protoc-gen-meshts. DO NOT EDIT.\n`; content += `// @generated by protoc-gen-meshts v1\n`; content += `// @generated from file ${file.name}.proto (package ${file.proto.package}, syntax proto3)\n`; content += `/* eslint-disable */\n`; @@ -317,9 +318,11 @@ function generateServiceClientString( content += " }\n"; content += "\n"; content += " // Create the gRPC-Web transport for browser with interceptors\n"; + content += " // Custom fetch wrapper to include credentials for cookie-based authentication\n"; content += " const transport = createGrpcWebTransport({\n"; content += " baseUrl: this._config.apiServerURL,\n"; content += " interceptors: this._interceptors,\n"; + content += ' fetch: (input, init) => fetch(input, { ...init, credentials: "include" }),\n'; content += " });\n"; content += "\n"; content += " // Construct the Connect-ES client\n";