Skip to content

Commit 8299c55

Browse files
Copilothotlong
andcommitted
Add /api/v1/index.json handler to fix ObjectStackClient.connect() error
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 38be6ed commit 8299c55

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.storybook/mocks.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,16 @@ export const handlers = [
1818
// - /api/v1/data/:object/:id (GET, PUT, DELETE)
1919
// - /api/v1/metadata/*
2020
// - /api/bootstrap
21+
22+
// Handle /api/v1/index.json for ObjectStackClient.connect()
23+
http.get('/api/v1/index.json', async () => {
24+
return HttpResponse.json({
25+
version: '1.0',
26+
objects: ['contact', 'opportunity', 'account'],
27+
endpoints: {
28+
data: '/api/v1/data',
29+
metadata: '/api/v1/metadata'
30+
}
31+
});
32+
}),
2133
];

.storybook/msw-browser.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ export async function startMockServer() {
4545
baseUrl: '/api/v1',
4646
logRequests: true,
4747
customHandlers: [
48+
// Handle /api/v1/index.json for ObjectStackClient.connect()
49+
http.get('/api/v1/index.json', async () => {
50+
return HttpResponse.json({
51+
version: '1.0',
52+
objects: ['contact', 'opportunity', 'account'],
53+
endpoints: {
54+
data: '/api/v1/data',
55+
metadata: '/api/v1/metadata'
56+
}
57+
});
58+
}),
4859
// Explicitly handle all metadata requests to prevent pass-through
4960
http.get('/api/v1/metadata/*', async () => {
5061
return HttpResponse.json({});

0 commit comments

Comments
 (0)