Fix console 404s and navigation validation errors#412
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…rt navigation validation 1. browser.ts: Add legacy /api handlers alongside /api/v1 handlers so ObjectStackClient requests to /api/meta/... and /api/data/... are intercepted by MSW (fixes 404 errors). This matches the pattern already used in server.ts for tests. 2. objectstack.shared.ts: Change report navigation item from type:'report' (unsupported by @objectstack/objectql schema) to type:'url' with explicit path, eliminating Zod validation warnings while preserving the same navigation behavior. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes console “browser mode” breakage by ensuring MSW intercepts the base paths probed by ObjectStackClient, and resolves navigation Zod validation failures by using a supported navigation item type.
Changes:
- Add MSW handlers for both
/api/v1and legacy/apiin the browser worker setup to prevent 404s. - Change the injected CRM “report” navigation entry from unsupported
type: 'report'to supportedtype: 'url'pointing at the report route.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/console/src/mocks/browser.ts | Adds dual handler sets so MSW intercepts both /api/v1 and /api requests in browser mode. |
| apps/console/objectstack.shared.ts | Updates injected CRM navigation item to a supported url type to satisfy schema validation while preserving routing. |
| // Include both /api/v1 and legacy /api paths so the ObjectStackClient can | ||
| // reach the mock server regardless of which base URL it probes. | ||
| const v1Handlers = createHandlers('/api/v1', kernel, driver); | ||
| const legacyHandlers = createHandlers('/api', kernel, driver); | ||
| const handlers = [...v1Handlers, ...legacyHandlers]; |
There was a problem hiding this comment.
Calling createHandlers() twice duplicates the wildcard */.well-known/objectstack handler (and any other baseUrl-independent handlers inside createHandlers). It works, but it adds unnecessary duplication and makes future handler edits more error-prone due to ordering. Consider defining .well-known once outside createHandlers, or add an option to omit baseUrl-independent routes for the second call.
| id: 'nav_sales_report', | ||
| type: 'report', | ||
| reportName: 'sales_performance_q1', | ||
| type: 'url', | ||
| url: '/apps/crm_app/report/sales_performance_q1', | ||
| label: 'Sales Report', |
There was a problem hiding this comment.
The injected report link hardcodes the app name (/apps/crm_app/...) even though crmApp.name is available. Using the actual app name from the config avoids drift if the CRM example app name ever changes or if this patch is reused for a different app.
Console browser mode fails because MSW handlers only intercept
/api/v1/...butObjectStackClientrequests/api/.... Additionally,type: 'report'navigation items fail@objectstack/objectqlZod validation.MSW handler path mismatch (
browser.ts): Added legacy/apihandlers alongside/api/v1, matching the patternserver.tsalready uses for tests:Navigation schema validation (
objectstack.shared.ts): Changed injected report nav item from unsupportedtype: 'report'totype: 'url'with explicit path. AppSidebar rendersurlitems via React Router<Link>, so behavior is preserved.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.