@decocms/start 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/start",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "type": "module",
5
5
  "description": "Deco framework for TanStack Start - CMS bridge, admin protocol, hooks, schema generation",
6
6
  "main": "./src/index.ts",
@@ -126,6 +126,13 @@ export async function handleInvoke(request: Request): Promise<Response> {
126
126
 
127
127
  try {
128
128
  const result = await found.handler(body, request);
129
+ // Response passthrough: if the loader/action returns a Response object,
130
+ // forward it as-is (preserving headers like Set-Cookie). This matches
131
+ // deco-cx/deco's invokeToHttpResponse behavior where auth loaders return
132
+ // Response objects with Set-Cookie headers for HttpOnly cookies.
133
+ if (result instanceof Response) {
134
+ return result;
135
+ }
129
136
  const filtered = selectFields(result, select);
130
137
  return new Response(JSON.stringify(filtered), { status: 200, headers: JSON_HEADERS });
131
138
  } catch (error) {
@@ -145,7 +152,13 @@ export async function handleInvoke(request: Request): Promise<Response> {
145
152
 
146
153
  if (found) {
147
154
  try {
148
- const result = await found.handler(payload, request);
155
+ let result = await found.handler(payload, request);
156
+ // If a loader returns a Response, extract its JSON body for batching.
157
+ // Set-Cookie headers from batch items are not forwarded individually
158
+ // (use single invoke for auth loaders that need cookie passthrough).
159
+ if (result instanceof Response) {
160
+ try { result = await result.json(); } catch { result = null; }
161
+ }
149
162
  results[key] = selectFields(result, select);
150
163
  } catch (error) {
151
164
  results[key] = { error: (error as Error).message };