Skip to content

Commit a3a9d66

Browse files
Copilothotlong
andcommitted
Fix console browser errors: add legacy /api MSW handlers and fix report 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>
1 parent 5284191 commit a3a9d66

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

apps/console/objectstack.shared.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const crmConfig = (crmConfigImport as any).default || crmConfigImport;
77
const todoConfig = (todoConfigImport as any).default || todoConfigImport;
88
const kitchenSinkConfig = (kitchenSinkConfigImport as any).default || kitchenSinkConfigImport;
99

10-
// Patch CRM App Navigation to include Report (since it was removed from CRM config for strict validation)
10+
// Patch CRM App Navigation to include Report using a supported navigation type
11+
// (type: 'url' passes schema validation while still routing correctly via React Router)
1112
const crmApps = crmConfig.apps ? JSON.parse(JSON.stringify(crmConfig.apps)) : [];
1213
if (crmApps.length > 0) {
1314
const crmApp = crmApps[0];
@@ -17,8 +18,8 @@ if (crmApps.length > 0) {
1718
const insertIdx = dashboardIdx !== -1 ? dashboardIdx + 1 : 0;
1819
crmApp.navigation.splice(insertIdx, 0, {
1920
id: 'nav_sales_report',
20-
type: 'report',
21-
reportName: 'sales_performance_q1',
21+
type: 'url',
22+
url: '/apps/crm_app/report/sales_performance_q1',
2223
label: 'Sales Report',
2324
icon: 'file-bar-chart'
2425
});

apps/console/src/mocks/browser.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ export async function startMockServer() {
5252
await kernel.bootstrap();
5353

5454
// Create MSW handlers that match the response format of HonoServerPlugin
55-
const baseUrl = '/api/v1';
56-
const handlers = createHandlers(baseUrl, kernel, driver);
55+
// Include both /api/v1 and legacy /api paths so the ObjectStackClient can
56+
// reach the mock server regardless of which base URL it probes.
57+
const v1Handlers = createHandlers('/api/v1', kernel, driver);
58+
const legacyHandlers = createHandlers('/api', kernel, driver);
59+
const handlers = [...v1Handlers, ...legacyHandlers];
5760

5861
// Start MSW service worker
5962
worker = setupWorker(...handlers);

0 commit comments

Comments
 (0)