From 144b96d954ca436bec44ff2741284014708a1f06 Mon Sep 17 00:00:00 2001 From: Bernard Bussy Date: Thu, 20 Nov 2025 19:05:51 +0100 Subject: [PATCH] feat(ts-web): add credentials support and DO NOT EDIT header to generated clients MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update TypeScript web client generator to include credentials in fetch configuration for cookie-based authentication and cross-origin requests. Also add idiomatic DO NOT EDIT comment to generated file headers. Changes: - Add fetch wrapper with credentials: 'include' to createGrpcWebTransport - Add DO NOT EDIT comment following Go convention - Use cleaner arrow function syntax for fetch override 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tool/protoc-gen-mesh_ts_web/src/index.ts | 3 +++ 1 file changed, 3 insertions(+) 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";