Skip to content

Commit 3cbc128

Browse files
BRBussyclaude
andauthored
feat(ts-web): add credentials support and DO NOT EDIT header to generated clients (#122)
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 <[email protected]>
1 parent 6e4e841 commit 3cbc128

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tool/protoc-gen-mesh_ts_web/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function generateConnectClientManually(schema: Schema, file: DescFile) {
2929
let content = "";
3030

3131
// Add file header
32+
content += `// Code generated by protoc-gen-meshts. DO NOT EDIT.\n`;
3233
content += `// @generated by protoc-gen-meshts v1\n`;
3334
content += `// @generated from file ${file.name}.proto (package ${file.proto.package}, syntax proto3)\n`;
3435
content += `/* eslint-disable */\n`;
@@ -317,9 +318,11 @@ function generateServiceClientString(
317318
content += " }\n";
318319
content += "\n";
319320
content += " // Create the gRPC-Web transport for browser with interceptors\n";
321+
content += " // Custom fetch wrapper to include credentials for cookie-based authentication\n";
320322
content += " const transport = createGrpcWebTransport({\n";
321323
content += " baseUrl: this._config.apiServerURL,\n";
322324
content += " interceptors: this._interceptors,\n";
325+
content += ' fetch: (input, init) => fetch(input, { ...init, credentials: "include" }),\n';
323326
content += " });\n";
324327
content += "\n";
325328
content += " // Construct the Connect-ES client\n";

0 commit comments

Comments
 (0)