-
Notifications
You must be signed in to change notification settings - Fork 1
Fix discovery API path missing /api/v1 prefix on Vercel deployment #1064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,6 +106,13 @@ export function createRequestHandler(options: SvelteKitAdapterOptions) { | |
| }); | ||
| } | ||
|
|
||
| if (segments.length === 1 && segments[0] === 'discovery' && method === 'GET') { | ||
| return new Response(JSON.stringify({ data: await dispatcher.getDiscoveryInfo(prefix) }), { | ||
| status: 200, | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }); | ||
| } | ||
|
|
||
| try { | ||
| // --- Auth (needs auth service integration) --- | ||
| if (segments[0] === 'auth') { | ||
|
|
@@ -176,7 +183,7 @@ export function createRequestHandler(options: SvelteKitAdapterOptions) { | |
| const queryParams: Record<string, any> = {}; | ||
| url.searchParams.forEach((val, key) => { queryParams[key] = val; }); | ||
|
|
||
| const result = await dispatcher.dispatch(method, subPath, body, queryParams, { request }); | ||
| const result = await dispatcher.dispatch(method, subPath, body, queryParams, { request }, prefix); | ||
| return toResponse(result); | ||
|
Comment on lines
183
to
187
|
||
| } catch (err: any) { | ||
| return errorJson(err.message || 'Internal Server Error', err.statusCode || 500); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -228,6 +228,23 @@ export class MSWPlugin implements Plugin { | |
| }) | ||
| ); | ||
|
|
||
| // Explicit /discovery endpoint — must be registered before catch-all | ||
| // so dispatch() is not called with an empty prefix. | ||
| this.handlers.push( | ||
| http.get(`*${baseUrl}`, async () => { | ||
| if (this.dispatcher) { | ||
| return HttpResponse.json({ data: await this.dispatcher.getDiscoveryInfo(baseUrl) }); | ||
| } | ||
| return HttpResponse.json({ data: { version: 'v1', url: baseUrl } }); | ||
| }), | ||
| http.get(`*${baseUrl}/discovery`, async () => { | ||
| if (this.dispatcher) { | ||
| return HttpResponse.json({ data: await this.dispatcher.getDiscoveryInfo(baseUrl) }); | ||
| } | ||
| return HttpResponse.json({ data: { version: 'v1', url: baseUrl } }); | ||
| }) | ||
|
Comment on lines
+234
to
+245
|
||
| ); | ||
|
|
||
| if (this.dispatcher) { | ||
| const dispatcher = this.dispatcher; | ||
|
|
||
|
|
@@ -271,7 +288,8 @@ export class MSWPlugin implements Plugin { | |
| path, | ||
| body, | ||
| query, | ||
| { request } | ||
| { request }, | ||
| baseUrl | ||
| ); | ||
|
|
||
| if (result.handled) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The adapter now passes a 6th
prefixargument todispatcher.dispatch(...), but the existing Fastify adapter unit tests still assert the old 5-argument call signature (seepackages/adapters/fastify/src/fastify.test.ts). This will cause the test suite to fail unless the expectations are updated to include the prefix (e.g.'/api'/ custom prefix) and ideally add coverage for the newGET ${prefix}/discoveryroute.