feat: init
This commit is contained in:
15
node_modules/@nuxt/nitro-server/dist/runtime/utils/error.mjs
generated
vendored
Normal file
15
node_modules/@nuxt/nitro-server/dist/runtime/utils/error.mjs
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { getRequestHeader } from "h3";
|
||||
/**
|
||||
* Nitro internal functions extracted from https://github.com/nitrojs/nitro/blob/v2/src/runtime/internal/utils.ts
|
||||
*/
|
||||
export function isJsonRequest(event) {
|
||||
// If the client specifically requests HTML, then avoid classifying as JSON.
|
||||
if (hasReqHeader(event, "accept", "text/html")) {
|
||||
return false;
|
||||
}
|
||||
return hasReqHeader(event, "accept", "application/json") || hasReqHeader(event, "user-agent", "curl/") || hasReqHeader(event, "user-agent", "httpie/") || hasReqHeader(event, "sec-fetch-mode", "cors") || event.path.startsWith("/api/") || event.path.endsWith(".json");
|
||||
}
|
||||
export function hasReqHeader(event, name, includes) {
|
||||
const value = getRequestHeader(event, name);
|
||||
return value && typeof value === "string" && value.toLowerCase().includes(includes);
|
||||
}
|
||||
Reference in New Issue
Block a user