Repository navigation
Self hosting Comments Data - #24
Conversation
|
|
||
| // [Velt] API key and auth token from environment variables | ||
| const NEXT_PUBLIC_VELT_API_KEY = "6xTcUFtlYAlCdh11zrKB"; | ||
| const VELT_AUTH_TOKEN = "bd4d5226050470b6c658054fcdf1092a"; |
There was a problem hiding this comment.
Bug: Hardcoded auth token exposes server credentials in source
The VELT_AUTH_TOKEN is a server-side secret that's hardcoded directly in the source code despite the comment stating these are "from environment variables." This auth token is used to authenticate API requests to Velt's servers and could allow unauthorized access if the repository is public or shared. The credentials are identical across both MongoDB and PostgreSQL demo files. Server-side secrets like auth tokens need to be read from environment variables at runtime, not committed to source control.
Additional Locations (1)
| } else { | ||
| // 3. Generate new document ID | ||
| docId = `doc-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`; | ||
| localStorage.setItem('velt-inline-comments-demo-doc-id', docId); |
There was a problem hiding this comment.
Bug: Inconsistent localStorage keys break document persistence
Two different localStorage keys are used for document ID persistence, causing stored documents to be lost. When a URL contains a documentId parameter, the code stores to 'velt-demo-document-id' (line 48), but when checking for an existing document on subsequent visits, it reads from 'velt-inline-comments-demo-doc-id' (line 51). This mismatch means users who visit via a shared link will lose access to that document's comments on their next visit without the URL parameter, as a new document ID will be generated instead of retrieving the stored one.
Additional Locations (1)
ec57c42 to
29c16f8
Compare
| NEXT_PUBLIC_VELT_API_KEY=6xTcUFtlYAlCdh11zrKB | ||
| VELT_API_KEY=6xTcUFtlYAlCdh11zrKB | ||
| VELT_AUTH_TOKEN=bd4d5226050470b6c658054fcdf1092a | ||
| MONGODB_URI="mongodb+srv://yoen_db_user:eEtxXKvkpgFfYT4w@democluster.dhaarnp.mongodb.net/velt_comments?appName=DemoCluster" |
There was a problem hiding this comment.
Bug: Database credentials committed to version control
The .env.local files contain real credentials that are being committed to version control. The MongoDB file includes a connection string with plaintext username (yoen_db_user) and password (eEtxXKvkpgFfYT4w) for a MongoDB Atlas cluster, plus VELT_AUTH_TOKEN. The repository's .gitignore doesn't exclude .env.local files. These credentials should be removed from version control, rotated immediately, and a .env.example file with placeholder values used instead.
Additional Locations (1)
| // Extract documentId and organizationId from metadata | ||
| const documentId = metadata?.documentId; | ||
| const organizationId = metadata?.organizationId; | ||
| await saveComments(commentAnnotation, { documentId, organizationId }); |
There was a problem hiding this comment.
Bug: Metadata extraction from request body will always be undefined
The save route handler extracts metadata from the top level of the request body, but according to the type definition in VeltCommentDataProvider.ts, the request structure only contains commentAnnotation at the top level—metadata is nested inside each individual annotation, not at the request root. This means metadata will always be undefined, causing documentId and organizationId to be undefined when passed to saveComments. The code relies on the fallback in store.ts (annotation.documentId), but if Velt doesn't populate these fields directly on annotations, comments won't be properly associated with their documents, breaking filtering and retrieval by documentIds.
Additional Locations (1)
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request
Description
Type of Change
Monorepo Structure Checklist
If adding a new demo, ensure you've followed the 5-level structure:
apps/<framework>/<document>/<type>/<implementation>/<library-or-solution>/<demo>/package.jsonwith scoped name:@apps/<framework>-<document>-<library-or-solution>-<demo>pnpm --filter <package-name> buildpnpm --filter <package-name> devDeployment Checklist
If this demo should be deployed:
Testing
pnpm -w install && pnpm -w buildDocumentation
master-sample-app(if applicable)Related Issues
Screenshots/Videos
Additional Context
For Reviewers
Demo Location
Path:
apps/<framework>/<document>/<type>/<implementation>/<library-or-solution>/<demo>/Package name:
@apps/<...>How to Test
Structure Verification
The demo follows the 5-level hierarchy:
Documentation: See README_MONOREPO.md and docs/structure.md for more details on the monorepo structure.
Note
Adds a MongoDB-backed self-hosted comments implementation with API routes and data provider for the dashboard demo, and removes the open-envoy demo.
app/api/velt/comments/store.tsand Next.js API routes:comments/get,comments/save,comments/delete.commentDataProviderinVeltProviderand integrate inline comments (VeltInlineCommentsSection,VeltCommentTool,VeltCommentBubble) with context metadata.VeltCollaboration, initialize document/user) and UI customizations.apps/react/comments/dashboard/self-hosting/dashboard-mongo-db-demowith full layout, components, and styles.mongodb@^7and related lockfile entries.open-envoy-demoapp and its files.Written by Cursor Bugbot for commit 6032197. This will update automatically on new commits. Configure here.