feat: complete SSR CRM and refine auth UI
This commit is contained in:
@@ -1482,13 +1482,27 @@ export function createHandlers(deps: RuntimeDeps): Handlers {
|
||||
});
|
||||
const apiCtx = createContext(apiReq, apiUrl);
|
||||
apiCtx.locals = ctx.locals;
|
||||
apiCtx.user = ctx.user;
|
||||
apiCtx.tenant = ctx.tenant;
|
||||
apiCtx.tracer = ctx.tracer;
|
||||
apiCtx.ip = ctx.ip;
|
||||
apiCtx.lang = ctx.lang;
|
||||
apiCtx.t = ctx.t;
|
||||
apiCtx.params = ctx.params;
|
||||
apiCtx.cookies = ctx.cookies;
|
||||
apiCtx.session = ctx.session;
|
||||
apiCtx.localStorage = ctx.localStorage;
|
||||
|
||||
const apiRes = await handleApi(apiCtx);
|
||||
if (!apiRes.ok) {
|
||||
throw new Error(`API route ${apiUrl.pathname} returned ${apiRes.status}`);
|
||||
const contentType = apiRes.headers.get("content-type") ?? "";
|
||||
const data = contentType.includes("application/json")
|
||||
? await apiRes.json().catch(() => undefined)
|
||||
: await apiRes.text().catch(() => undefined);
|
||||
throw Object.assign(new Error(`API route ${apiUrl.pathname} returned ${apiRes.status}`), {
|
||||
status: apiRes.status,
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
const contentType = apiRes.headers.get("content-type") ?? "";
|
||||
|
||||
Reference in New Issue
Block a user