feat(ts-web): Add credentials support and improve generated client headers #122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Enhances the TypeScript Web SDK code generator to improve browser authentication support and code clarity.
Changes
1. Add Credentials Support for Cookie Authentication
Problem:
Browser applications using cookie-based authentication (especially Next.js with SSR) need
credentials: 'include'in fetch requests to properly send HTTP-only cookies.Solution:
Updated the
protoc-gen-mesh_ts_webgenerator to include a custom fetch wrapper in the gRPC-Web transport configuration:Impact:
AccessToken)2. Add "DO NOT EDIT" Header to Generated Files
Problem:
Generated files lacked clear indication that they shouldn't be manually edited.
Solution:
Added idiomatic "DO NOT EDIT" comment following Go convention:
Impact:
Architecture Context
The TypeScript Web SDK supports dual-environment usage in Next.js:
Browser (Client Components):
Next.js Server (Server Components/API Routes):
Both patterns now work seamlessly with the updated generator.
Files Changed
Modified
tool/protoc-gen-mesh_ts_web/src/index.ts(+3 lines)Regenerated (10 files)
All generated TypeScript Web service clients now include:
Testing
yarn build)Breaking Changes
None - these are additive improvements that enhance existing functionality.
Related Documentation
See
thoughts/ts-web-sdk-improvements.mdfor comprehensive SDK review and future improvement roadmap.🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com