fix: resolve apiProxy via ctx.get for /model (v0.3.2)
Cordis throws on ctx.apiProxy without inject; use ctx.get and declare apiProxy inject so catalog and model APIs work under dsh web. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Resolve host apiProxy without requiring Cordis inject.
|
||||
* Direct `ctx.apiProxy` throws "cannot get property without inject" on real fibers.
|
||||
*/
|
||||
export function resolveApiProxy(ctx) {
|
||||
const c = ctx;
|
||||
if (typeof c.get === 'function') {
|
||||
try {
|
||||
const viaGet = c.get('apiProxy');
|
||||
if (viaGet)
|
||||
return viaGet;
|
||||
}
|
||||
catch {
|
||||
// ignore and try own-property fallback (tests / plain mocks)
|
||||
}
|
||||
}
|
||||
try {
|
||||
// Own property on plain mocks only — Cordis proxy throws without inject.
|
||||
if (Object.prototype.hasOwnProperty.call(c, 'apiProxy') && c.apiProxy) {
|
||||
return c.apiProxy;
|
||||
}
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user