@catmint/adapter-vercel 0.0.0-prealpha.2 → 0.0.0-prealpha.20
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/dist/config-gen.d.ts +3 -0
- package/dist/config-gen.d.ts.map +1 -1
- package/dist/config-gen.js +35 -2
- package/dist/config-gen.js.map +1 -1
- package/dist/function-gen.d.ts +1 -1
- package/dist/function-gen.d.ts.map +1 -1
- package/dist/function-gen.js +536 -69
- package/dist/function-gen.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +74 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/config-gen.d.ts
CHANGED
package/dist/config-gen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-gen.d.ts","sourceRoot":"","sources":["../src/config-gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,KAAK,CAAC;QACV,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;QAC7C,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,UAAU,kBAAkB;IAC1B,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAA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,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9C;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,WAAW,GAAG,YAAY,CA6GxE"}
|
package/dist/config-gen.js
CHANGED
|
@@ -40,7 +40,11 @@ export function generateVercelConfig(manifest) {
|
|
|
40
40
|
dest: "/index",
|
|
41
41
|
});
|
|
42
42
|
// 3. Process manifest routes
|
|
43
|
+
// Skip static routes without middleware — they are served directly from
|
|
44
|
+
// the static/ directory via { handle: "filesystem" } below.
|
|
43
45
|
for (const route of [...manifest.routes, ...manifest.endpoints]) {
|
|
46
|
+
if (route.renderMode === "static" && !route.hasMiddleware)
|
|
47
|
+
continue;
|
|
44
48
|
const src = routePathToVercelSrc(route.path);
|
|
45
49
|
// For cached routes with prerender configs, route to the dedicated function
|
|
46
50
|
const routeName = route.cache && route.path !== "/"
|
|
@@ -69,11 +73,25 @@ export function generateVercelConfig(manifest) {
|
|
|
69
73
|
}
|
|
70
74
|
routes.push(vercelRoute);
|
|
71
75
|
}
|
|
72
|
-
// 4.
|
|
76
|
+
// 4. Rewrite middleware-protected static routes to the serverless function.
|
|
77
|
+
// These paths have pre-rendered HTML but must go through middleware, so
|
|
78
|
+
// they MUST NOT be served from the static/ directory by Vercel's CDN.
|
|
79
|
+
// This rewrite rule runs BEFORE { handle: "filesystem" } to intercept
|
|
80
|
+
// the request before Vercel checks for a matching static file.
|
|
81
|
+
for (const route of manifest.routes) {
|
|
82
|
+
if (route.hasMiddleware && route.renderMode === "static") {
|
|
83
|
+
const src = routePathToVercelSrc(route.path);
|
|
84
|
+
routes.push({
|
|
85
|
+
src,
|
|
86
|
+
dest: "/index",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// 5. Check the filesystem (static/ directory) before the catch-all.
|
|
73
91
|
// Without this, the catch-all below would intercept requests for static
|
|
74
92
|
// assets (JS, CSS, images) and send them to the serverless function.
|
|
75
93
|
routes.push({ handle: "filesystem" });
|
|
76
|
-
//
|
|
94
|
+
// 6. Fallback: rewrite all unmatched requests to the serverless function
|
|
77
95
|
// This only triggers for requests that didn't match a static file above.
|
|
78
96
|
if (manifest.mode !== "frontend") {
|
|
79
97
|
routes.push({
|
|
@@ -81,9 +99,24 @@ export function generateVercelConfig(manifest) {
|
|
|
81
99
|
dest: "/index",
|
|
82
100
|
});
|
|
83
101
|
}
|
|
102
|
+
// 7. Build overrides map for static routes.
|
|
103
|
+
// Pre-rendered HTML is written as e.g. "about.html" but the browser
|
|
104
|
+
// requests "/about" (clean URL). Vercel's filesystem handler does an
|
|
105
|
+
// exact path match, so without overrides it won't find the .html file
|
|
106
|
+
// and the request falls through to the catch-all serverless function.
|
|
107
|
+
// The overrides map tells Vercel to serve "about.html" for path "about".
|
|
108
|
+
const overrides = {};
|
|
109
|
+
for (const route of manifest.routes) {
|
|
110
|
+
if (route.renderMode === "static" && !route.hasMiddleware) {
|
|
111
|
+
const cleanPath = route.path === "/" ? "index" : route.path.replace(/^\//, "");
|
|
112
|
+
const htmlFile = cleanPath + ".html";
|
|
113
|
+
overrides[htmlFile] = { path: cleanPath };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
84
116
|
return {
|
|
85
117
|
version: 3,
|
|
86
118
|
routes,
|
|
119
|
+
...(Object.keys(overrides).length > 0 ? { overrides } : {}),
|
|
87
120
|
};
|
|
88
121
|
}
|
|
89
122
|
//# sourceMappingURL=config-gen.js.map
|
package/dist/config-gen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-gen.js","sourceRoot":"","sources":["../src/config-gen.ts"],"names":[],"mappings":"AAAA,0EAA0E;
|
|
1
|
+
{"version":3,"file":"config-gen.js","sourceRoot":"","sources":["../src/config-gen.ts"],"names":[],"mappings":"AAAA,0EAA0E;AA4C1E;;;;;;;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"edge", regions?: s
|
|
|
36
36
|
* function registers a platform cache adapter that delegates invalidation
|
|
37
37
|
* to Vercel's on-demand ISR revalidation API.
|
|
38
38
|
*/
|
|
39
|
-
export declare function generateServerlessFunction(manifest: AppManifest, runtime: "nodejs" | "edge"): string;
|
|
39
|
+
export declare function generateServerlessFunction(manifest: AppManifest, runtime: "nodejs" | "edge", maxBodySize: number, headerPreset: "baseline" | "none"): string;
|
|
40
40
|
export {};
|
|
41
41
|
//# sourceMappingURL=function-gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-gen.d.ts","sourceRoot":"","sources":["../src/function-gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,QAAQ,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,KAAK,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAC;AAmF9C;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,QAAQ,GAAG,MAAM,EAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,QAAQ,CAqBV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,QAAQ,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"function-gen.d.ts","sourceRoot":"","sources":["../src/function-gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,QAAQ,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,KAAK,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAC;AAmF9C;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,QAAQ,GAAG,MAAM,EAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,QAAQ,CAqBV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,QAAQ,GAAG,MAAM,EAC1B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,UAAU,GAAG,MAAM,GAChC,MAAM,CAKR"}
|
package/dist/function-gen.js
CHANGED
|
@@ -112,27 +112,79 @@ export function generateVcConfig(runtime, regions) {
|
|
|
112
112
|
* function registers a platform cache adapter that delegates invalidation
|
|
113
113
|
* to Vercel's on-demand ISR revalidation API.
|
|
114
114
|
*/
|
|
115
|
-
export function generateServerlessFunction(manifest, runtime) {
|
|
115
|
+
export function generateServerlessFunction(manifest, runtime, maxBodySize, headerPreset) {
|
|
116
116
|
if (runtime === "edge") {
|
|
117
|
-
return generateEdgeFunction(manifest);
|
|
117
|
+
return generateEdgeFunction(manifest, maxBodySize, headerPreset);
|
|
118
118
|
}
|
|
119
|
-
return generateNodejsFunction(manifest);
|
|
119
|
+
return generateNodejsFunction(manifest, maxBodySize, headerPreset);
|
|
120
120
|
}
|
|
121
|
-
function generateNodejsFunction(manifest) {
|
|
121
|
+
function generateNodejsFunction(manifest, maxBodySize, headerPreset) {
|
|
122
122
|
const cacheAdapterSetup = generateCacheAdapterSetup(manifest);
|
|
123
123
|
return `// Auto-generated by @catmint/adapter-vercel (Node.js runtime) — do not edit
|
|
124
124
|
import * as rscEntry from "./rsc/index.js";
|
|
125
125
|
import * as ssrEntry from "./ssr/index.js";
|
|
126
|
+
import { readFile, stat } from "node:fs/promises";
|
|
127
|
+
import { join, extname } from "node:path";
|
|
128
|
+
import { fileURLToPath } from "node:url";
|
|
129
|
+
import { createHash } from "node:crypto";
|
|
130
|
+
|
|
131
|
+
function __isClientSafeErrorLike(err) {
|
|
132
|
+
return err != null && typeof err === "object" && err.constructor && err.constructor.name === "ClientSafeError" && typeof err.statusCode === "number";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function __isRedirectErrorLike(err) {
|
|
136
|
+
return err != null && typeof err === "object" && err.constructor && err.constructor.name === "RedirectError" && typeof err.url === "string" && typeof err.status === "number";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function __errorRef(err) {
|
|
140
|
+
var msg = (err && typeof err === "object" && err.message) ? String(err.message) : "unknown";
|
|
141
|
+
return createHash("sha256").update(msg + Date.now()).digest("hex").slice(0, 8);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
145
|
+
const PRERENDERED_DIR = join(__dirname, "prerendered");
|
|
126
146
|
${cacheAdapterSetup}
|
|
127
147
|
function collectBody(req) {
|
|
148
|
+
const MAX_BODY_SIZE = ${maxBodySize};
|
|
128
149
|
return new Promise((resolve, reject) => {
|
|
129
150
|
const chunks = [];
|
|
130
|
-
|
|
151
|
+
let totalLength = 0;
|
|
152
|
+
req.on("data", (chunk) => {
|
|
153
|
+
totalLength += chunk.length;
|
|
154
|
+
if (totalLength > MAX_BODY_SIZE) {
|
|
155
|
+
req.destroy();
|
|
156
|
+
reject(new Error("Request body too large"));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
chunks.push(chunk);
|
|
160
|
+
});
|
|
131
161
|
req.on("end", () => resolve(Buffer.concat(chunks)));
|
|
132
162
|
req.on("error", reject);
|
|
133
163
|
});
|
|
134
164
|
}
|
|
135
165
|
|
|
166
|
+
function nodeReqToWebRequest(req) {
|
|
167
|
+
const protocol = "https";
|
|
168
|
+
const host = req.headers.host || "localhost";
|
|
169
|
+
const reqUrl = new URL(req.url || "/", \`\${protocol}://\${host}\`);
|
|
170
|
+
const headers = new Headers();
|
|
171
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
172
|
+
if (value) {
|
|
173
|
+
if (Array.isArray(value)) {
|
|
174
|
+
for (const v of value) {
|
|
175
|
+
headers.append(key, v);
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
headers.set(key, value);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return new Request(reqUrl.href, {
|
|
183
|
+
method: req.method || "GET",
|
|
184
|
+
headers,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
136
188
|
async function pipeWebStreamToResponse(webStream, res) {
|
|
137
189
|
const reader = webStream.getReader();
|
|
138
190
|
try {
|
|
@@ -216,40 +268,203 @@ function __catmintErrorPage(statusCode, detail) {
|
|
|
216
268
|
}
|
|
217
269
|
|
|
218
270
|
export default async function handler(req, res) {
|
|
271
|
+
${headerPreset === "baseline"
|
|
272
|
+
? ` // Baseline security headers
|
|
273
|
+
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
274
|
+
res.setHeader("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
275
|
+
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
276
|
+
`
|
|
277
|
+
: ""}
|
|
219
278
|
const url = new URL(req.url || "/", \`https://\${req.headers.host || "localhost"}\`);
|
|
220
279
|
const pathname = url.pathname;
|
|
221
280
|
const method = (req.method || "GET").toUpperCase();
|
|
222
281
|
|
|
282
|
+
// Establish the request-scoped AsyncLocalStorage context.
|
|
283
|
+
// This makes cookies(), headers(), getPlatform() etc. available
|
|
284
|
+
// to server functions, middleware, API endpoints, and RSC rendering.
|
|
285
|
+
const __webRequest = nodeReqToWebRequest(req);
|
|
286
|
+
const __store = ssrEntry.createRequestStore(__webRequest, { req, res });
|
|
287
|
+
await ssrEntry.runWithRequestContext(__store, async () => {
|
|
288
|
+
|
|
289
|
+
// Helper: flush pending Set-Cookie headers and accumulated response
|
|
290
|
+
// headers from the request store onto the Node.js response object.
|
|
291
|
+
function __flushPendingHeaders() {
|
|
292
|
+
// Apply accumulated response headers
|
|
293
|
+
__store.responseHeaders.forEach(function(value, key) {
|
|
294
|
+
res.setHeader(key, value);
|
|
295
|
+
});
|
|
296
|
+
// Apply pending Set-Cookie headers
|
|
297
|
+
var cookies = [];
|
|
298
|
+
__store.pendingCookies.forEach(function(pending) {
|
|
299
|
+
cookies.push(pending.serialized);
|
|
300
|
+
});
|
|
301
|
+
if (cookies.length > 0) {
|
|
302
|
+
res.setHeader("Set-Cookie", cookies);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
223
306
|
try {
|
|
224
|
-
// 1.
|
|
307
|
+
// 1. Middleware execution — runs for all routes handled by this function.
|
|
308
|
+
// For RSC flight requests, run middleware against the TARGET page path
|
|
309
|
+
// (from ?path= query param), not the literal /__catmint/rsc pathname.
|
|
310
|
+
var middlewareHeaders = null;
|
|
311
|
+
if (ssrEntry.executeMiddleware) {
|
|
312
|
+
try {
|
|
313
|
+
var middlewarePath = pathname;
|
|
314
|
+
if (pathname === "/__catmint/rsc") {
|
|
315
|
+
var rscTargetPath = url.searchParams.get("path");
|
|
316
|
+
if (rscTargetPath) middlewarePath = rscTargetPath;
|
|
317
|
+
}
|
|
318
|
+
var webRequest = nodeReqToWebRequest(req);
|
|
319
|
+
var mwResult = await ssrEntry.executeMiddleware(middlewarePath, webRequest);
|
|
320
|
+
|
|
321
|
+
if (mwResult.shortCircuit) {
|
|
322
|
+
// Middleware short-circuited — return its response directly
|
|
323
|
+
res.statusCode = mwResult.shortCircuit.status;
|
|
324
|
+
mwResult.shortCircuit.headers.forEach(function(value, key) {
|
|
325
|
+
res.setHeader(key, value);
|
|
326
|
+
});
|
|
327
|
+
__flushPendingHeaders();
|
|
328
|
+
var scBody = await mwResult.shortCircuit.text();
|
|
329
|
+
res.end(scBody);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Middleware passed — capture headers to merge into final response
|
|
334
|
+
if (mwResult.headers && typeof mwResult.headers.forEach === "function") {
|
|
335
|
+
middlewareHeaders = mwResult.headers;
|
|
336
|
+
}
|
|
337
|
+
} catch (err) {
|
|
338
|
+
console.error("Middleware error:", err);
|
|
339
|
+
if (!res.headersSent) {
|
|
340
|
+
__flushPendingHeaders();
|
|
341
|
+
res.statusCode = 500;
|
|
342
|
+
res.end("Internal Server Error");
|
|
343
|
+
}
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Helper: merge middleware headers into the response before sending.
|
|
349
|
+
function applyMiddlewareHeaders() {
|
|
350
|
+
if (middlewareHeaders) {
|
|
351
|
+
middlewareHeaders.forEach(function(value, key) {
|
|
352
|
+
res.setHeader(key, value);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// 2. Handle server function RPC calls (/__catmint/fn/*)
|
|
225
358
|
if (pathname.startsWith("/__catmint/fn/") && ssrEntry.handleServerFn) {
|
|
359
|
+
// Enforce POST method
|
|
360
|
+
if (method !== "POST") {
|
|
361
|
+
__flushPendingHeaders();
|
|
362
|
+
res.statusCode = 405;
|
|
363
|
+
res.setHeader("Content-Type", "application/json");
|
|
364
|
+
res.end(JSON.stringify({ error: "Method " + method + " not allowed, expected POST" }));
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Enforce Content-Type: application/json
|
|
369
|
+
const ct = (req.headers["content-type"] || "").toLowerCase();
|
|
370
|
+
if (ct && !ct.startsWith("application/json")) {
|
|
371
|
+
__flushPendingHeaders();
|
|
372
|
+
res.statusCode = 415;
|
|
373
|
+
res.setHeader("Content-Type", "application/json");
|
|
374
|
+
res.end(JSON.stringify({ error: "Unsupported Content-Type, expected application/json" }));
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Validate Origin header
|
|
379
|
+
const origin = req.headers["origin"];
|
|
380
|
+
if (origin) {
|
|
381
|
+
const expectedHost = req.headers.host || "localhost";
|
|
382
|
+
if (origin !== \`https://\${expectedHost}\` && origin !== \`http://\${expectedHost}\`) {
|
|
383
|
+
__flushPendingHeaders();
|
|
384
|
+
res.statusCode = 403;
|
|
385
|
+
res.setHeader("Content-Type", "application/json");
|
|
386
|
+
res.end(JSON.stringify({ error: "Origin not allowed" }));
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
226
391
|
const body = await collectBody(req);
|
|
227
392
|
let parsed;
|
|
228
393
|
try {
|
|
229
394
|
parsed = body.length > 0 ? JSON.parse(body.toString("utf-8")) : undefined;
|
|
230
395
|
} catch {
|
|
396
|
+
__flushPendingHeaders();
|
|
231
397
|
res.statusCode = 400;
|
|
232
398
|
res.setHeader("Content-Type", "application/json");
|
|
233
399
|
res.end(JSON.stringify({ error: "Invalid JSON body" }));
|
|
234
400
|
return;
|
|
235
401
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
402
|
+
try {
|
|
403
|
+
const result = await ssrEntry.handleServerFn(pathname, parsed);
|
|
404
|
+
if (result) {
|
|
405
|
+
// Check if the result IS a ClientSafeError (returned, not thrown)
|
|
406
|
+
if (__isClientSafeErrorLike(result.result)) {
|
|
407
|
+
applyMiddlewareHeaders();
|
|
408
|
+
__flushPendingHeaders();
|
|
409
|
+
res.statusCode = 200;
|
|
410
|
+
res.setHeader("Content-Type", "application/json");
|
|
411
|
+
res.end(JSON.stringify({
|
|
412
|
+
__clientSafeError: true,
|
|
413
|
+
error: result.result.message,
|
|
414
|
+
statusCode: result.result.statusCode,
|
|
415
|
+
data: result.result.data,
|
|
416
|
+
}));
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
applyMiddlewareHeaders();
|
|
420
|
+
__flushPendingHeaders();
|
|
421
|
+
res.statusCode = 200;
|
|
422
|
+
res.setHeader("Content-Type", "application/json");
|
|
423
|
+
res.end(JSON.stringify(result.result));
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
__flushPendingHeaders();
|
|
427
|
+
res.statusCode = 404;
|
|
239
428
|
res.setHeader("Content-Type", "application/json");
|
|
240
|
-
res.end(JSON.stringify(
|
|
241
|
-
|
|
429
|
+
res.end(JSON.stringify({ error: "Server function not found" }));
|
|
430
|
+
} catch (err) {
|
|
431
|
+
// Always log full error server-side
|
|
432
|
+
console.error("[catmint] Server function error:", err);
|
|
433
|
+
|
|
434
|
+
// RedirectError — send redirect envelope
|
|
435
|
+
if (__isRedirectErrorLike(err)) {
|
|
436
|
+
__flushPendingHeaders();
|
|
437
|
+
res.statusCode = 200;
|
|
438
|
+
res.setHeader("Content-Type", "application/json");
|
|
439
|
+
res.end(JSON.stringify({ __redirect: true, url: err.url, status: err.status }));
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// ClientSafeError — developer opted in, expose to client
|
|
444
|
+
if (__isClientSafeErrorLike(err)) {
|
|
445
|
+
__flushPendingHeaders();
|
|
446
|
+
res.statusCode = err.statusCode;
|
|
447
|
+
res.setHeader("Content-Type", "application/json");
|
|
448
|
+
res.end(JSON.stringify({ error: err.message, data: err.data }));
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Default: sanitize — generic message with correlation hash
|
|
453
|
+
const ref = __errorRef(err);
|
|
454
|
+
console.error("[catmint] Error reference [ref: " + ref + "] — see above for full error");
|
|
455
|
+
__flushPendingHeaders();
|
|
456
|
+
res.statusCode = 500;
|
|
457
|
+
res.setHeader("Content-Type", "application/json");
|
|
458
|
+
res.end(JSON.stringify({ error: "Internal Server Error [ref: " + ref + "]" }));
|
|
242
459
|
}
|
|
243
|
-
res.statusCode = 404;
|
|
244
|
-
res.setHeader("Content-Type", "application/json");
|
|
245
|
-
res.end(JSON.stringify({ error: "Server function not found" }));
|
|
246
460
|
return;
|
|
247
461
|
}
|
|
248
462
|
|
|
249
|
-
//
|
|
463
|
+
// 3. RSC flight stream for client-side navigation (/__catmint/rsc?path=...)
|
|
250
464
|
if (pathname === "/__catmint/rsc" && method === "GET" && rscEntry.render) {
|
|
251
465
|
const targetPath = url.searchParams.get("path");
|
|
252
466
|
if (!targetPath) {
|
|
467
|
+
__flushPendingHeaders();
|
|
253
468
|
res.statusCode = 400;
|
|
254
469
|
res.setHeader("Content-Type", "application/json");
|
|
255
470
|
res.end(JSON.stringify({ error: "Missing ?path= parameter" }));
|
|
@@ -258,18 +473,22 @@ export default async function handler(req, res) {
|
|
|
258
473
|
try {
|
|
259
474
|
const rscResult = await rscEntry.render(targetPath);
|
|
260
475
|
if (rscResult) {
|
|
476
|
+
applyMiddlewareHeaders();
|
|
477
|
+
__flushPendingHeaders();
|
|
261
478
|
res.statusCode = 200;
|
|
262
479
|
res.setHeader("Content-Type", "text/x-component; charset=utf-8");
|
|
263
480
|
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
|
264
481
|
await pipeWebStreamToResponse(rscResult.stream, res);
|
|
265
482
|
return;
|
|
266
483
|
}
|
|
484
|
+
__flushPendingHeaders();
|
|
267
485
|
res.statusCode = 404;
|
|
268
486
|
res.setHeader("Content-Type", "application/json");
|
|
269
487
|
res.end(JSON.stringify({ error: "No matching route" }));
|
|
270
488
|
} catch (err) {
|
|
271
489
|
console.error("RSC navigation error:", err);
|
|
272
490
|
if (!res.headersSent) {
|
|
491
|
+
__flushPendingHeaders();
|
|
273
492
|
res.statusCode = 500;
|
|
274
493
|
res.setHeader("Content-Type", "application/json");
|
|
275
494
|
res.end(JSON.stringify({ error: "RSC navigation error" }));
|
|
@@ -278,7 +497,7 @@ export default async function handler(req, res) {
|
|
|
278
497
|
return;
|
|
279
498
|
}
|
|
280
499
|
|
|
281
|
-
//
|
|
500
|
+
// 4. API endpoint handling
|
|
282
501
|
if (ssrEntry.hasEndpoint && ssrEntry.hasEndpoint(pathname)) {
|
|
283
502
|
const fullUrl = \`https://\${req.headers.host || "localhost"}\${req.url || "/"}\`;
|
|
284
503
|
const requestInit = {
|
|
@@ -294,32 +513,79 @@ export default async function handler(req, res) {
|
|
|
294
513
|
}
|
|
295
514
|
|
|
296
515
|
const webRequest = new Request(fullUrl, requestInit);
|
|
297
|
-
const result = await ssrEntry.handleEndpoint(pathname, method, webRequest);
|
|
298
516
|
|
|
299
|
-
|
|
300
|
-
result.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
517
|
+
try {
|
|
518
|
+
const result = await ssrEntry.handleEndpoint(pathname, method, webRequest);
|
|
519
|
+
|
|
520
|
+
if (result) {
|
|
521
|
+
result.response.headers.forEach((value, key) => {
|
|
522
|
+
res.setHeader(key, value);
|
|
523
|
+
});
|
|
524
|
+
applyMiddlewareHeaders();
|
|
525
|
+
__flushPendingHeaders();
|
|
526
|
+
res.statusCode = result.response.status;
|
|
527
|
+
if (result.response.body) {
|
|
528
|
+
await pipeWebStreamToResponse(result.response.body, res);
|
|
529
|
+
} else {
|
|
530
|
+
res.end();
|
|
531
|
+
}
|
|
532
|
+
return;
|
|
308
533
|
}
|
|
534
|
+
|
|
535
|
+
__flushPendingHeaders();
|
|
536
|
+
res.statusCode = 405;
|
|
537
|
+
res.setHeader("Content-Type", "text/plain");
|
|
538
|
+
res.end(\`Method \${method} not allowed\`);
|
|
309
539
|
return;
|
|
540
|
+
} catch (err) {
|
|
541
|
+
// redirect() throws a RedirectError — convert to a real HTTP redirect
|
|
542
|
+
if (__isRedirectErrorLike(err)) {
|
|
543
|
+
__flushPendingHeaders();
|
|
544
|
+
res.writeHead(err.status, { "Location": err.url });
|
|
545
|
+
res.end();
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
throw err;
|
|
310
549
|
}
|
|
550
|
+
}
|
|
311
551
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
552
|
+
// 5. Pre-rendered pages WITH middleware: serve from function bundle.
|
|
553
|
+
// These are static routes that have middleware ancestors — their HTML
|
|
554
|
+
// was pre-rendered but placed in the function directory, not in
|
|
555
|
+
// Vercel's static/ directory (to avoid bypassing middleware).
|
|
556
|
+
if (method === "GET") {
|
|
557
|
+
let prerenderedPath = pathname;
|
|
558
|
+
if (!extname(prerenderedPath)) {
|
|
559
|
+
prerenderedPath = prerenderedPath.endsWith("/")
|
|
560
|
+
? prerenderedPath + "index.html"
|
|
561
|
+
: prerenderedPath + ".html";
|
|
562
|
+
}
|
|
563
|
+
try {
|
|
564
|
+
const prFilePath = join(PRERENDERED_DIR, prerenderedPath);
|
|
565
|
+
const prStats = await stat(prFilePath);
|
|
566
|
+
if (prStats.isFile()) {
|
|
567
|
+
const content = await readFile(prFilePath);
|
|
568
|
+
applyMiddlewareHeaders();
|
|
569
|
+
__flushPendingHeaders();
|
|
570
|
+
res.statusCode = 200;
|
|
571
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
572
|
+
res.setHeader("Content-Length", content.byteLength);
|
|
573
|
+
res.setHeader("Cache-Control", "public, max-age=0, must-revalidate");
|
|
574
|
+
res.end(content);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
} catch {
|
|
578
|
+
// No prerendered file — continue to RSC rendering
|
|
579
|
+
}
|
|
316
580
|
}
|
|
317
581
|
|
|
318
|
-
//
|
|
582
|
+
// 6. RSC → SSR page rendering pipeline
|
|
319
583
|
if (method === "GET" && rscEntry.render) {
|
|
320
584
|
const rscResult = await rscEntry.render(pathname);
|
|
321
585
|
if (rscResult) {
|
|
322
586
|
const htmlStream = await ssrEntry.renderToHtml(rscResult.stream, rscResult.headConfig);
|
|
587
|
+
applyMiddlewareHeaders();
|
|
588
|
+
__flushPendingHeaders();
|
|
323
589
|
res.statusCode = 200;
|
|
324
590
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
325
591
|
await pipeWebStreamToResponse(htmlStream, res);
|
|
@@ -327,21 +593,46 @@ export default async function handler(req, res) {
|
|
|
327
593
|
}
|
|
328
594
|
}
|
|
329
595
|
|
|
330
|
-
//
|
|
596
|
+
// 7. Fallback 404
|
|
597
|
+
__flushPendingHeaders();
|
|
331
598
|
await sendStatusPage(res, 404, pathname);
|
|
332
599
|
} catch (err) {
|
|
333
600
|
console.error("Serverless function error:", err);
|
|
601
|
+
__flushPendingHeaders();
|
|
334
602
|
await sendStatusPage(res, 500, pathname);
|
|
335
603
|
}
|
|
604
|
+
|
|
605
|
+
}); // end runWithRequestContext
|
|
336
606
|
}
|
|
337
607
|
`;
|
|
338
608
|
}
|
|
339
|
-
function generateEdgeFunction(manifest) {
|
|
609
|
+
function generateEdgeFunction(manifest, maxBodySize, headerPreset) {
|
|
340
610
|
const cacheAdapterSetup = generateCacheAdapterSetup(manifest);
|
|
611
|
+
// Check if there are middleware-protected static routes
|
|
612
|
+
const hasMiddlewareProtected = manifest.routes.some((r) => r.hasMiddleware && r.renderMode === "static");
|
|
341
613
|
return `// Auto-generated by @catmint/adapter-vercel (Edge runtime) — do not edit
|
|
342
614
|
import * as rscEntry from "./rsc/index.js";
|
|
343
615
|
import * as ssrEntry from "./ssr/index.js";
|
|
616
|
+
${hasMiddlewareProtected ? 'import { prerenderedPages } from "./prerendered.js";' : "var prerenderedPages = {};"}
|
|
344
617
|
${cacheAdapterSetup}
|
|
618
|
+
function __isClientSafeErrorLike(err) {
|
|
619
|
+
return err != null && typeof err === "object" && err.constructor && err.constructor.name === "ClientSafeError" && typeof err.statusCode === "number";
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function __isRedirectErrorLike(err) {
|
|
623
|
+
return err != null && typeof err === "object" && err.constructor && err.constructor.name === "RedirectError" && typeof err.url === "string" && typeof err.status === "number";
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
async function __errorRef(err) {
|
|
627
|
+
var msg = (err && typeof err === "object" && err.message) ? String(err.message) : "unknown";
|
|
628
|
+
var data = new TextEncoder().encode(msg + Date.now());
|
|
629
|
+
var buf = await crypto.subtle.digest("SHA-256", data);
|
|
630
|
+
var arr = new Uint8Array(buf);
|
|
631
|
+
var hex = "";
|
|
632
|
+
for (var i = 0; i < arr.length; i++) hex += arr[i].toString(16).padStart(2, "0");
|
|
633
|
+
return hex.slice(0, 8);
|
|
634
|
+
}
|
|
635
|
+
|
|
345
636
|
async function statusPageResponse(statusCode, pathname) {
|
|
346
637
|
if (rscEntry.renderStatusPage && ssrEntry.renderToHtml) {
|
|
347
638
|
try {
|
|
@@ -407,97 +698,273 @@ export default async function handler(request) {
|
|
|
407
698
|
const pathname = url.pathname;
|
|
408
699
|
const method = request.method.toUpperCase();
|
|
409
700
|
|
|
701
|
+
// Helper to create responses${headerPreset === "baseline" ? " with baseline security headers" : ""}
|
|
702
|
+
function secureResponse(body, init = {}) {
|
|
703
|
+
const headers = new Headers(init.headers || {});
|
|
704
|
+
${headerPreset === "baseline"
|
|
705
|
+
? ` headers.set("X-Content-Type-Options", "nosniff");
|
|
706
|
+
headers.set("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
707
|
+
headers.set("X-Frame-Options", "SAMEORIGIN");
|
|
708
|
+
`
|
|
709
|
+
: ""} return new Response(body, { ...init, headers });
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// Establish the request-scoped AsyncLocalStorage context.
|
|
713
|
+
// This makes cookies(), headers(), getPlatform() etc. available
|
|
714
|
+
// to server functions, middleware, API endpoints, and RSC rendering.
|
|
715
|
+
const __store = ssrEntry.createRequestStore(request, { request });
|
|
716
|
+
return ssrEntry.runWithRequestContext(__store, async () => {
|
|
717
|
+
|
|
718
|
+
// Helper: flush pending Set-Cookie headers and accumulated response
|
|
719
|
+
// headers from the request store onto the outgoing Response.
|
|
720
|
+
function __flushHeaders(response) {
|
|
721
|
+
return ssrEntry.applyPendingHeaders(response, __store);
|
|
722
|
+
}
|
|
723
|
+
|
|
410
724
|
try {
|
|
411
|
-
// 1.
|
|
725
|
+
// 1. Middleware execution — runs for all routes handled by this function.
|
|
726
|
+
// For RSC flight requests, run middleware against the TARGET page path
|
|
727
|
+
// (from ?path= query param), not the literal /__catmint/rsc pathname.
|
|
728
|
+
var middlewareHeaders = null;
|
|
729
|
+
if (ssrEntry.executeMiddleware) {
|
|
730
|
+
try {
|
|
731
|
+
var middlewarePath = pathname;
|
|
732
|
+
if (pathname === "/__catmint/rsc") {
|
|
733
|
+
var rscTargetPath = url.searchParams.get("path");
|
|
734
|
+
if (rscTargetPath) middlewarePath = rscTargetPath;
|
|
735
|
+
}
|
|
736
|
+
var mwResult = await ssrEntry.executeMiddleware(middlewarePath, request);
|
|
737
|
+
|
|
738
|
+
if (mwResult.shortCircuit) {
|
|
739
|
+
// Middleware short-circuited — return its response directly
|
|
740
|
+
return __flushHeaders(mwResult.shortCircuit);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// Middleware passed — capture headers to merge into final response
|
|
744
|
+
if (mwResult.headers && typeof mwResult.headers.forEach === "function") {
|
|
745
|
+
middlewareHeaders = mwResult.headers;
|
|
746
|
+
}
|
|
747
|
+
} catch (err) {
|
|
748
|
+
console.error("Middleware error:", err);
|
|
749
|
+
return __flushHeaders(new Response("Internal Server Error", { status: 500 }));
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// Helper: create a new response with middleware headers merged in
|
|
754
|
+
function applyMiddlewareHeaders(response) {
|
|
755
|
+
if (!middlewareHeaders) return response;
|
|
756
|
+
var headers = new Headers(response.headers);
|
|
757
|
+
middlewareHeaders.forEach(function(value, key) {
|
|
758
|
+
headers.set(key, value);
|
|
759
|
+
});
|
|
760
|
+
return new Response(response.body, {
|
|
761
|
+
status: response.status,
|
|
762
|
+
headers,
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// 2. Handle server function RPC calls (/__catmint/fn/*)
|
|
412
767
|
if (pathname.startsWith("/__catmint/fn/") && ssrEntry.handleServerFn) {
|
|
768
|
+
// Enforce POST method
|
|
769
|
+
if (method !== "POST") {
|
|
770
|
+
return __flushHeaders(secureResponse(
|
|
771
|
+
JSON.stringify({ error: "Method " + method + " not allowed, expected POST" }),
|
|
772
|
+
{ status: 405, headers: { "Content-Type": "application/json" } },
|
|
773
|
+
));
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// Enforce Content-Type: application/json
|
|
777
|
+
const ct = (request.headers.get("content-type") || "").toLowerCase();
|
|
778
|
+
if (ct && !ct.startsWith("application/json")) {
|
|
779
|
+
return __flushHeaders(secureResponse(
|
|
780
|
+
JSON.stringify({ error: "Unsupported Content-Type, expected application/json" }),
|
|
781
|
+
{ status: 415, headers: { "Content-Type": "application/json" } },
|
|
782
|
+
));
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// Validate Origin header
|
|
786
|
+
const origin = request.headers.get("origin");
|
|
787
|
+
if (origin) {
|
|
788
|
+
const expectedOrigin = url.origin;
|
|
789
|
+
if (origin !== expectedOrigin) {
|
|
790
|
+
return __flushHeaders(secureResponse(
|
|
791
|
+
JSON.stringify({ error: "Origin not allowed" }),
|
|
792
|
+
{ status: 403, headers: { "Content-Type": "application/json" } },
|
|
793
|
+
));
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// Read body with size limit
|
|
798
|
+
const MAX_BODY_SIZE = ${maxBodySize};
|
|
799
|
+
const contentLength = parseInt(request.headers.get("content-length") || "0", 10);
|
|
800
|
+
if (contentLength > MAX_BODY_SIZE) {
|
|
801
|
+
return __flushHeaders(secureResponse(
|
|
802
|
+
JSON.stringify({ error: "Request body too large" }),
|
|
803
|
+
{ status: 413, headers: { "Content-Type": "application/json" } },
|
|
804
|
+
));
|
|
805
|
+
}
|
|
413
806
|
const bodyText = await request.text();
|
|
807
|
+
if (bodyText.length > MAX_BODY_SIZE) {
|
|
808
|
+
return __flushHeaders(secureResponse(
|
|
809
|
+
JSON.stringify({ error: "Request body too large" }),
|
|
810
|
+
{ status: 413, headers: { "Content-Type": "application/json" } },
|
|
811
|
+
));
|
|
812
|
+
}
|
|
414
813
|
let parsed;
|
|
415
814
|
try {
|
|
416
815
|
parsed = bodyText.length > 0 ? JSON.parse(bodyText) : undefined;
|
|
417
816
|
} catch {
|
|
418
|
-
return
|
|
817
|
+
return __flushHeaders(secureResponse(
|
|
419
818
|
JSON.stringify({ error: "Invalid JSON body" }),
|
|
420
819
|
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
421
|
-
);
|
|
820
|
+
));
|
|
422
821
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
822
|
+
try {
|
|
823
|
+
const result = await ssrEntry.handleServerFn(pathname, parsed);
|
|
824
|
+
if (result) {
|
|
825
|
+
// Check if the result IS a ClientSafeError (returned, not thrown)
|
|
826
|
+
if (__isClientSafeErrorLike(result.result)) {
|
|
827
|
+
return __flushHeaders(applyMiddlewareHeaders(secureResponse(JSON.stringify({
|
|
828
|
+
__clientSafeError: true,
|
|
829
|
+
error: result.result.message,
|
|
830
|
+
statusCode: result.result.statusCode,
|
|
831
|
+
data: result.result.data,
|
|
832
|
+
}), {
|
|
833
|
+
status: 200,
|
|
834
|
+
headers: { "Content-Type": "application/json" },
|
|
835
|
+
})));
|
|
836
|
+
}
|
|
837
|
+
return __flushHeaders(applyMiddlewareHeaders(secureResponse(JSON.stringify(result.result), {
|
|
838
|
+
status: 200,
|
|
839
|
+
headers: { "Content-Type": "application/json" },
|
|
840
|
+
})));
|
|
841
|
+
}
|
|
842
|
+
return __flushHeaders(secureResponse(
|
|
843
|
+
JSON.stringify({ error: "Server function not found" }),
|
|
844
|
+
{ status: 404, headers: { "Content-Type": "application/json" } },
|
|
845
|
+
));
|
|
846
|
+
} catch (err) {
|
|
847
|
+
// Always log full error server-side
|
|
848
|
+
console.error("[catmint] Server function error:", err);
|
|
849
|
+
|
|
850
|
+
// RedirectError — send redirect envelope
|
|
851
|
+
if (__isRedirectErrorLike(err)) {
|
|
852
|
+
return __flushHeaders(secureResponse(
|
|
853
|
+
JSON.stringify({ __redirect: true, url: err.url, status: err.status }),
|
|
854
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
855
|
+
));
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// ClientSafeError — developer opted in, expose to client
|
|
859
|
+
if (__isClientSafeErrorLike(err)) {
|
|
860
|
+
return __flushHeaders(secureResponse(
|
|
861
|
+
JSON.stringify({ error: err.message, data: err.data }),
|
|
862
|
+
{ status: err.statusCode, headers: { "Content-Type": "application/json" } },
|
|
863
|
+
));
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// Default: sanitize — generic message with correlation hash
|
|
867
|
+
const ref = await __errorRef(err);
|
|
868
|
+
console.error("[catmint] Error reference [ref: " + ref + "] — see above for full error");
|
|
869
|
+
return __flushHeaders(secureResponse(
|
|
870
|
+
JSON.stringify({ error: "Internal Server Error [ref: " + ref + "]" }),
|
|
871
|
+
{ status: 500, headers: { "Content-Type": "application/json" } },
|
|
872
|
+
));
|
|
429
873
|
}
|
|
430
|
-
return new Response(
|
|
431
|
-
JSON.stringify({ error: "Server function not found" }),
|
|
432
|
-
{ status: 404, headers: { "Content-Type": "application/json" } },
|
|
433
|
-
);
|
|
434
874
|
}
|
|
435
875
|
|
|
436
|
-
//
|
|
876
|
+
// 3. RSC flight stream for client-side navigation (/__catmint/rsc?path=...)
|
|
437
877
|
if (pathname === "/__catmint/rsc" && method === "GET" && rscEntry.render) {
|
|
438
878
|
const targetPath = url.searchParams.get("path");
|
|
439
879
|
if (!targetPath) {
|
|
440
|
-
return
|
|
880
|
+
return __flushHeaders(secureResponse(
|
|
441
881
|
JSON.stringify({ error: "Missing ?path= parameter" }),
|
|
442
882
|
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
443
|
-
);
|
|
883
|
+
));
|
|
444
884
|
}
|
|
445
885
|
try {
|
|
446
886
|
const rscResult = await rscEntry.render(targetPath);
|
|
447
887
|
if (rscResult) {
|
|
448
|
-
return
|
|
888
|
+
return __flushHeaders(applyMiddlewareHeaders(secureResponse(rscResult.stream, {
|
|
449
889
|
status: 200,
|
|
450
890
|
headers: {
|
|
451
891
|
"Content-Type": "text/x-component; charset=utf-8",
|
|
452
892
|
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
453
893
|
},
|
|
454
|
-
});
|
|
894
|
+
})));
|
|
455
895
|
}
|
|
456
|
-
return
|
|
896
|
+
return __flushHeaders(secureResponse(
|
|
457
897
|
JSON.stringify({ error: "No matching route" }),
|
|
458
898
|
{ status: 404, headers: { "Content-Type": "application/json" } },
|
|
459
|
-
);
|
|
899
|
+
));
|
|
460
900
|
} catch (err) {
|
|
461
901
|
console.error("RSC navigation error:", err);
|
|
462
|
-
return
|
|
902
|
+
return __flushHeaders(secureResponse(
|
|
463
903
|
JSON.stringify({ error: "RSC navigation error" }),
|
|
464
904
|
{ status: 500, headers: { "Content-Type": "application/json" } },
|
|
465
|
-
);
|
|
905
|
+
));
|
|
466
906
|
}
|
|
467
907
|
}
|
|
468
908
|
|
|
469
|
-
//
|
|
909
|
+
// 4. API endpoint handling
|
|
470
910
|
if (ssrEntry.hasEndpoint && ssrEntry.hasEndpoint(pathname)) {
|
|
471
|
-
|
|
911
|
+
try {
|
|
912
|
+
const result = await ssrEntry.handleEndpoint(pathname, method, request);
|
|
913
|
+
|
|
914
|
+
if (result) {
|
|
915
|
+
return __flushHeaders(applyMiddlewareHeaders(result.response));
|
|
916
|
+
}
|
|
472
917
|
|
|
473
|
-
|
|
474
|
-
|
|
918
|
+
return __flushHeaders(secureResponse(\`Method \${method} not allowed\`, {
|
|
919
|
+
status: 405,
|
|
920
|
+
headers: { "Content-Type": "text/plain" },
|
|
921
|
+
}));
|
|
922
|
+
} catch (err) {
|
|
923
|
+
// redirect() throws a RedirectError — convert to a real HTTP redirect
|
|
924
|
+
if (__isRedirectErrorLike(err)) {
|
|
925
|
+
return __flushHeaders(new Response(null, {
|
|
926
|
+
status: err.status,
|
|
927
|
+
headers: { "Location": err.url },
|
|
928
|
+
}));
|
|
929
|
+
}
|
|
930
|
+
throw err;
|
|
475
931
|
}
|
|
932
|
+
}
|
|
476
933
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
934
|
+
// 5. Pre-rendered pages WITH middleware: serve from inlined prerendered map.
|
|
935
|
+
if (method === "GET" && Object.keys(prerenderedPages).length > 0) {
|
|
936
|
+
const prHtml = prerenderedPages[pathname];
|
|
937
|
+
if (prHtml) {
|
|
938
|
+
return __flushHeaders(applyMiddlewareHeaders(secureResponse(prHtml, {
|
|
939
|
+
status: 200,
|
|
940
|
+
headers: {
|
|
941
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
942
|
+
"Cache-Control": "public, max-age=0, must-revalidate",
|
|
943
|
+
},
|
|
944
|
+
})));
|
|
945
|
+
}
|
|
481
946
|
}
|
|
482
947
|
|
|
483
|
-
//
|
|
948
|
+
// 6. RSC → SSR page rendering pipeline
|
|
484
949
|
if (method === "GET" && rscEntry.render) {
|
|
485
950
|
const rscResult = await rscEntry.render(pathname);
|
|
486
951
|
if (rscResult) {
|
|
487
952
|
const htmlStream = await ssrEntry.renderToHtml(rscResult.stream, rscResult.headConfig);
|
|
488
|
-
return
|
|
953
|
+
return __flushHeaders(applyMiddlewareHeaders(secureResponse(htmlStream, {
|
|
489
954
|
status: 200,
|
|
490
955
|
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
491
|
-
});
|
|
956
|
+
})));
|
|
492
957
|
}
|
|
493
958
|
}
|
|
494
959
|
|
|
495
|
-
//
|
|
496
|
-
return await statusPageResponse(404, pathname);
|
|
960
|
+
// 7. Fallback 404
|
|
961
|
+
return __flushHeaders(await statusPageResponse(404, pathname));
|
|
497
962
|
} catch (err) {
|
|
498
963
|
console.error("Edge function error:", err);
|
|
499
|
-
return await statusPageResponse(500, pathname);
|
|
964
|
+
return __flushHeaders(await statusPageResponse(500, pathname));
|
|
500
965
|
}
|
|
966
|
+
|
|
967
|
+
}); // end runWithRequestContext
|
|
501
968
|
}
|
|
502
969
|
`;
|
|
503
970
|
}
|
package/dist/function-gen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-gen.js","sourceRoot":"","sources":["../src/function-gen.ts"],"names":[],"mappings":"AAAA,kEAAkE;AA2BlE;;GAEG;AACH,SAAS,gBAAgB,CAAC,QAAqB;IAC7C,MAAM,WAAW,GAA6B,EAAE,CAAC;IACjD,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;YACtB,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;gBACnC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;oBACtB,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;gBACxB,CAAC;gBACD,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,yBAAyB,CAAC,QAAqB;IACtD,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2KxC,CAAC;AACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ export interface VercelAdapterOptions {
|
|
|
7
7
|
runtime?: "nodejs" | "edge";
|
|
8
8
|
/** Vercel regions to deploy to */
|
|
9
9
|
regions?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Maximum allowed request body size in bytes.
|
|
12
|
+
* Applies to server function RPC calls and API endpoints.
|
|
13
|
+
*
|
|
14
|
+
* @default 1_048_576 (1 MB)
|
|
15
|
+
*/
|
|
16
|
+
maxBodySize?: number;
|
|
10
17
|
}
|
|
11
18
|
/**
|
|
12
19
|
* Create a Vercel adapter for Catmint.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,gBAAgB,CAAC;AAmExB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,cAAc,CA6MhB"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,52 @@
|
|
|
1
1
|
// @catmint/adapter-vercel — Vercel deployment adapter
|
|
2
|
-
import { join } from "node:path";
|
|
2
|
+
import { join, relative } from "node:path";
|
|
3
|
+
import { readFileSync, readdirSync, statSync, existsSync } from "node:fs";
|
|
3
4
|
import { generateVercelConfig } from "./config-gen.js";
|
|
4
5
|
import { generateServerlessFunction, generateVcConfig, } from "./function-gen.js";
|
|
6
|
+
/**
|
|
7
|
+
* Generate a JS module that exports a map of pathname → HTML string
|
|
8
|
+
* for prerendered pages. Used by edge runtimes that cannot read from
|
|
9
|
+
* the filesystem at runtime.
|
|
10
|
+
*/
|
|
11
|
+
function generatePrerenderedModule(prerenderedDir) {
|
|
12
|
+
const entries = [];
|
|
13
|
+
function walk(dir) {
|
|
14
|
+
if (!existsSync(dir))
|
|
15
|
+
return;
|
|
16
|
+
for (const entry of readdirSync(dir)) {
|
|
17
|
+
const fullPath = join(dir, entry);
|
|
18
|
+
const stat = statSync(fullPath);
|
|
19
|
+
if (stat.isDirectory()) {
|
|
20
|
+
walk(fullPath);
|
|
21
|
+
}
|
|
22
|
+
else if (entry.endsWith(".html")) {
|
|
23
|
+
const relPath = relative(prerenderedDir, fullPath);
|
|
24
|
+
let pathname = "/" + relPath.replace(/\\/g, "/");
|
|
25
|
+
if (pathname.endsWith("/index.html")) {
|
|
26
|
+
pathname = pathname.slice(0, -"/index.html".length) || "/";
|
|
27
|
+
}
|
|
28
|
+
else if (pathname.endsWith(".html")) {
|
|
29
|
+
pathname = pathname.slice(0, -".html".length);
|
|
30
|
+
}
|
|
31
|
+
const html = readFileSync(fullPath, "utf-8");
|
|
32
|
+
entries.push({ pathname, html });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
walk(prerenderedDir);
|
|
37
|
+
if (entries.length === 0) {
|
|
38
|
+
return `// No prerendered pages\nexport const prerenderedPages = {};\n`;
|
|
39
|
+
}
|
|
40
|
+
const lines = [
|
|
41
|
+
"// Auto-generated prerendered page map — do not edit",
|
|
42
|
+
"export const prerenderedPages = {",
|
|
43
|
+
];
|
|
44
|
+
for (const { pathname, html } of entries) {
|
|
45
|
+
lines.push(` ${JSON.stringify(pathname)}: ${JSON.stringify(html)},`);
|
|
46
|
+
}
|
|
47
|
+
lines.push("};");
|
|
48
|
+
return lines.join("\n") + "\n";
|
|
49
|
+
}
|
|
5
50
|
/**
|
|
6
51
|
* Create a Vercel adapter for Catmint.
|
|
7
52
|
*
|
|
@@ -20,6 +65,7 @@ import { generateServerlessFunction, generateVcConfig, } from "./function-gen.js
|
|
|
20
65
|
export default function vercelAdapter(options) {
|
|
21
66
|
const runtime = options?.runtime ?? "nodejs";
|
|
22
67
|
const regions = options?.regions;
|
|
68
|
+
const maxBodySize = options?.maxBodySize ?? 1_048_576;
|
|
23
69
|
return {
|
|
24
70
|
name: "@catmint/adapter-vercel",
|
|
25
71
|
async adapt(context) {
|
|
@@ -39,6 +85,8 @@ export default function vercelAdapter(options) {
|
|
|
39
85
|
await context.copyDir(context.clientDir, staticOutputDir);
|
|
40
86
|
context.log("@catmint/adapter-vercel: Copied client assets to static/");
|
|
41
87
|
// 3. Copy pre-rendered static pages to static/
|
|
88
|
+
// NOTE: Middleware-protected static pages are NOT copied here — they
|
|
89
|
+
// are served through the serverless function after middleware runs.
|
|
42
90
|
await context.copyDir(context.staticDir, staticOutputDir);
|
|
43
91
|
context.log("@catmint/adapter-vercel: Copied pre-rendered pages to static/");
|
|
44
92
|
// 4. Generate serverless function (only if not frontend-only mode)
|
|
@@ -52,10 +100,25 @@ export default function vercelAdapter(options) {
|
|
|
52
100
|
// import both without filename conflicts.
|
|
53
101
|
await context.copyDir(context.serverDir, join(funcDir, "ssr"));
|
|
54
102
|
await context.copyDir(rscDir, join(funcDir, "rsc"));
|
|
103
|
+
// If there are prerendered pages with middleware, handle them based
|
|
104
|
+
// on the runtime:
|
|
105
|
+
// - Node.js: copy files to function dir (served via filesystem reads)
|
|
106
|
+
// - Edge: generate a JS module with inlined HTML (no fs access at runtime)
|
|
107
|
+
if (context.prerenderedDir && existsSync(context.prerenderedDir)) {
|
|
108
|
+
if (runtime === "edge") {
|
|
109
|
+
const prerenderedModule = generatePrerenderedModule(context.prerenderedDir);
|
|
110
|
+
await context.writeFile(join(funcDir, "prerendered.js"), prerenderedModule);
|
|
111
|
+
context.log("@catmint/adapter-vercel: Generated prerendered.js module (middleware-protected, edge)");
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
await context.copyDir(context.prerenderedDir, join(funcDir, "prerendered"));
|
|
115
|
+
context.log("@catmint/adapter-vercel: Copied prerendered HTML to function (middleware-protected)");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
55
118
|
// Generate the serverless function entry as handler.js.
|
|
56
119
|
// This imports from ./ssr/index.js and ./rsc/index.js and wraps
|
|
57
120
|
// them with the Vercel serverless function handler signature.
|
|
58
|
-
const functionEntry = generateServerlessFunction(manifest, runtime);
|
|
121
|
+
const functionEntry = generateServerlessFunction(manifest, runtime, maxBodySize, manifest.config.security.headerPreset);
|
|
59
122
|
await context.writeFile(join(funcDir, "handler.js"), functionEntry);
|
|
60
123
|
// Add package.json with "type": "module" so Node.js treats .js as ESM.
|
|
61
124
|
// The function directory is isolated from the project root, so without
|
|
@@ -81,6 +144,15 @@ export default function vercelAdapter(options) {
|
|
|
81
144
|
// The route function re-uses the same serverless entry and server bundle
|
|
82
145
|
await context.copyDir(context.serverDir, join(routeFuncDir, "ssr"));
|
|
83
146
|
await context.copyDir(rscDir, join(routeFuncDir, "rsc"));
|
|
147
|
+
if (context.prerenderedDir && existsSync(context.prerenderedDir)) {
|
|
148
|
+
if (runtime === "edge") {
|
|
149
|
+
const prerenderedModule = generatePrerenderedModule(context.prerenderedDir);
|
|
150
|
+
await context.writeFile(join(routeFuncDir, "prerendered.js"), prerenderedModule);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
await context.copyDir(context.prerenderedDir, join(routeFuncDir, "prerendered"));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
84
156
|
await context.writeFile(join(routeFuncDir, "handler.js"), functionEntry);
|
|
85
157
|
await context.writeFile(join(routeFuncDir, "package.json"), JSON.stringify({ type: "module" }, null, 2));
|
|
86
158
|
await context.writeFile(join(routeFuncDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAOtD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,SAAS,yBAAyB,CAAC,cAAsB;IACvD,MAAM,OAAO,GAA8C,EAAE,CAAC;IAE9D,SAAS,IAAI,CAAC,GAAW;QACvB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO;QAC7B,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACvB,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjB,CAAC;iBAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,cA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AQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAClC,OAAO,CAAC,GAAG,CACT,uDAAuD,EAAE,CAAC,IAAI,gBAAgB;oBAC5E,aAAa,SAAS,kDAAkD,CAC3E,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catmint/adapter-vercel",
|
|
3
|
-
"version": "0.0.0-prealpha.
|
|
3
|
+
"version": "0.0.0-prealpha.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "GPL-2.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"catmint": "0.0.0-prealpha.
|
|
17
|
+
"catmint": "0.0.0-prealpha.20"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"typescript": "^5.7.0"
|