nitro-nightly 3.0.1-20260102-142913-2fb634a2 → 3.0.1-20260105-130845-656a71ed
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/_dev.mjs
CHANGED
|
@@ -391,7 +391,7 @@ async function defaultHandler(error, event, opts) {
|
|
|
391
391
|
const ansiError = await (await youch.toANSI(error)).replaceAll(process.cwd(), ".");
|
|
392
392
|
consola$1.error(`[request error] ${tags} [${event.req.method}] ${url}\n\n`, ansiError);
|
|
393
393
|
}
|
|
394
|
-
const useJSON = opts?.json
|
|
394
|
+
const useJSON = opts?.json ?? !event.req.headers.get("accept")?.includes("text/html");
|
|
395
395
|
const headers = {
|
|
396
396
|
"content-type": useJSON ? "application/json" : "text/html",
|
|
397
397
|
"x-content-type-options": "nosniff",
|
|
@@ -44,7 +44,7 @@ export async function defaultHandler(error, event, opts) {
|
|
|
44
44
|
consola.error(`[request error] ${tags} [${event.req.method}] ${url}\n\n`, ansiError);
|
|
45
45
|
}
|
|
46
46
|
// Use HTML response only when user-agent expects it (browsers)
|
|
47
|
-
const useJSON = opts?.json
|
|
47
|
+
const useJSON = opts?.json ?? !event.req.headers.get("accept")?.includes("text/html");
|
|
48
48
|
// Prepare headers
|
|
49
49
|
const headers = {
|
|
50
50
|
"content-type": useJSON ? "application/json" : "text/html",
|
|
@@ -151,6 +151,10 @@ parentPort.on("message", (payload) => {
|
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
+
// Trap unhandled errors to avoid worker crash
|
|
155
|
+
process.on("unhandledRejection", (error) => console.error(error));
|
|
156
|
+
process.on("uncaughtException", (error) => console.error(error));
|
|
157
|
+
|
|
154
158
|
// ----- Server -----
|
|
155
159
|
|
|
156
160
|
async function reload() {
|
package/package.json
CHANGED