Skip to content

Commit 1c6c8b7

Browse files
Copilotjog1t
andcommitted
refactor: address code review feedback
Co-authored-by: jog1t <39823706+jog1t@users.noreply.github.com>
1 parent da6d6e6 commit 1c6c8b7

4 files changed

Lines changed: 200 additions & 18 deletions

File tree

UNIFIED_ENDPOINT_ROLLOUT.md

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Unified Endpoint Format Rollout
2+
3+
## Overview
4+
5+
This document describes the rollout of the unified endpoint format in Rivet UI and environment variables.
6+
7+
## What Changed
8+
9+
### Unified Endpoint Format
10+
11+
The unified endpoint format allows combining endpoint, namespace, and token into a single URL using HTTP Basic Auth syntax:
12+
13+
```
14+
https://namespace:token@api.rivet.dev
15+
```
16+
17+
This is more concise than the previous approach of using separate environment variables:
18+
19+
```bash
20+
# Old format (still supported)
21+
RIVET_ENDPOINT=https://api.rivet.dev
22+
RIVET_NAMESPACE=namespace
23+
RIVET_TOKEN=token
24+
25+
# New unified format (recommended)
26+
RIVET_ENDPOINT=https://namespace:token@api.rivet.dev
27+
```
28+
29+
### Changes Made
30+
31+
1. **UI Code Examples** (`frontend/src/app/publishable-token-code-group.tsx`)
32+
- JavaScript, React, and Next.js code examples now show the unified endpoint format
33+
- The endpoint URL automatically includes the namespace and token using URL encoding
34+
35+
2. **Environment Variables Component** (`frontend/src/app/env-variables.tsx`)
36+
- New `RivetEndpointEnvUnified` component that displays the unified endpoint format
37+
- Added `unified` prop (defaults to `true`) to toggle between formats
38+
- Backward compatibility maintained via the `unified` flag
39+
40+
3. **Tokens Page** (`frontend/src/routes/.../tokens.tsx`)
41+
- Added explanatory note about the unified endpoint format in the Client Token section
42+
43+
4. **Documentation** (`website/src/content/docs/self-hosting/connect-backend.mdx`)
44+
- Documented both unified and separate variable formats
45+
- Added comparison and recommendations
46+
- Updated all examples to show both approaches
47+
48+
## Backward Compatibility
49+
50+
**Fully backward compatible** - Both formats are supported:
51+
52+
- Existing deployments using separate `RIVET_ENDPOINT`, `RIVET_NAMESPACE`, and `RIVET_TOKEN` variables will continue to work
53+
- New deployments can use the unified format
54+
- Users can choose the format that works best for their workflow
55+
56+
## Rollout Steps
57+
58+
### For UI Users
59+
60+
1. **View Updated Code Examples**
61+
- Navigate to the Tokens page in the Rivet dashboard
62+
- Code examples (JavaScript, React, Next.js) now show the unified endpoint format
63+
- Copy the provided code and use it in your application
64+
65+
2. **Environment Variables**
66+
- When viewing environment variables in the Connect dialogs, you'll see the unified `RIVET_ENDPOINT` format by default
67+
- The endpoint URL includes the namespace and token embedded in it
68+
69+
### For Documentation Users
70+
71+
1. **Read Updated Docs**
72+
- Visit `/docs/self-hosting/connect-backend` for detailed information
73+
- Both formats are documented with examples
74+
- Choose the format that fits your deployment workflow
75+
76+
### For Self-Hosted Users
77+
78+
No action required. Both formats are supported and parsed by RivetKit:
79+
80+
- The endpoint parser (`rivetkit-typescript/packages/rivetkit/src/utils/endpoint-parser.ts`) automatically extracts namespace and token from URLs
81+
- Existing environment variable parsing continues to work as before
82+
83+
## Testing Recommendations
84+
85+
### Smoke Tests
86+
87+
1. **Client Token Flow**
88+
- [ ] Create a new namespace
89+
- [ ] View the Client Token section
90+
- [ ] Verify code examples show unified endpoint format
91+
- [ ] Copy code and test in a sample application
92+
93+
2. **Environment Variables**
94+
- [ ] Open Connect > Manual dialog
95+
- [ ] Verify environment variables show unified format
96+
- [ ] Copy and test in deployment
97+
98+
3. **Documentation**
99+
- [ ] Visit `/docs/self-hosting/connect-backend`
100+
- [ ] Verify both formats are documented
101+
- [ ] Try examples from documentation
102+
103+
### Integration Tests
104+
105+
1. **URL Parsing**
106+
- Test that `https://namespace:token@api.rivet.dev` correctly extracts:
107+
- endpoint: `https://api.rivet.dev/`
108+
- namespace: `namespace`
109+
- token: `token`
110+
111+
2. **Backward Compatibility**
112+
- Test that separate env vars still work:
113+
```bash
114+
RIVET_ENDPOINT=https://api.rivet.dev
115+
RIVET_NAMESPACE=test
116+
RIVET_TOKEN=pub_test123
117+
```
118+
119+
3. **Client Connection**
120+
- Test client creation with unified endpoint
121+
- Verify authentication works correctly
122+
123+
## Migration Guide (Optional)
124+
125+
Users can optionally migrate to the unified format:
126+
127+
### Before (Separate Variables)
128+
129+
```bash
130+
RIVET_ENDPOINT=https://api-us-west-1.rivet.dev
131+
RIVET_NAMESPACE=my-namespace
132+
RIVET_TOKEN=pub_abc123xyz
133+
```
134+
135+
### After (Unified Format)
136+
137+
```bash
138+
RIVET_ENDPOINT=https://my-namespace:pub_abc123xyz@api-us-west-1.rivet.dev
139+
```
140+
141+
**Note:** URL encoding is handled automatically by the URL API, but if setting this manually in shell scripts, ensure special characters are encoded.
142+
143+
## Benefits
144+
145+
1. **Simpler Configuration**: One variable instead of three
146+
2. **Less Error-Prone**: No risk of mismatching endpoint/namespace/token
147+
3. **Familiar Pattern**: Uses standard HTTP Basic Auth URL syntax
148+
4. **Cleaner Code**: Client code is more concise
149+
150+
## Rollback Plan
151+
152+
If issues are discovered:
153+
154+
1. The `unified` prop in `EnvVariables` component can be set to `false` to revert to the old format
155+
2. Documentation can be updated to recommend the separate format
156+
3. UI code examples can be rolled back by reverting the commits
157+
158+
## Support
159+
160+
For questions or issues related to this rollout:
161+
162+
1. Check the updated documentation at `/docs/self-hosting/connect-backend`
163+
2. Review the endpoint parser tests in `rivetkit-typescript/packages/rivetkit/src/utils/endpoint-parser.test.ts`
164+
3. Open an issue on GitHub with the `FRONT-904` label
165+
166+
## Related Files
167+
168+
- `frontend/src/app/publishable-token-code-group.tsx` - Code examples component
169+
- `frontend/src/app/env-variables.tsx` - Environment variables display
170+
- `frontend/src/routes/.../tokens.tsx` - Tokens page
171+
- `website/src/content/docs/self-hosting/connect-backend.mdx` - Documentation
172+
- `rivetkit-typescript/packages/rivetkit/src/utils/endpoint-parser.ts` - URL parsing logic

frontend/src/app/env-variables.tsx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/app/publishable-token-code-group.tsx

Lines changed: 21 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/src/content/docs/self-hosting/connect-backend.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,20 @@ Both formats are supported. Choose the one that works best for your deployment w
5959
The endpoint of your Rivet Engine instance. Can include namespace and token in unified format.
6060

6161
```bash
62-
# Unified format (recommended)
62+
# Unified format (recommended) - only supported by RIVET_ENDPOINT
6363
RIVET_ENDPOINT=https://my-namespace:pub_abc123@api.rivet.dev
6464

6565
# Or separate endpoint only
6666
RIVET_ENDPOINT=https://api.rivet.dev
6767

68-
# Legacy alias (still supported)
68+
# Legacy alias RIVET_ENGINE (endpoint only, no unified format)
6969
RIVET_ENGINE=http://localhost:6420
7070
```
7171

72+
<Note>
73+
`RIVET_ENGINE` is a legacy alias for `RIVET_ENDPOINT` that only supports endpoint-only configuration. Use `RIVET_ENDPOINT` for the unified format with embedded credentials.
74+
</Note>
75+
7276
### `RIVET_TOKEN`
7377
Authentication token for accessing the Rivet Engine (when not using unified endpoint format).
7478

0 commit comments

Comments
 (0)