mirror of
https://github.com/JonasunderscoreJones/api.jonasjones.dev.git
synced 2025-10-23 20:19:19 +02:00
Initial commit (by create-cloudflare CLI)
This commit is contained in:
commit
58a42872a0
1745 changed files with 741893 additions and 0 deletions
40
node_modules/wrangler/templates/middleware/middleware-pretty-error.ts
generated
vendored
Normal file
40
node_modules/wrangler/templates/middleware/middleware-pretty-error.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import type { Middleware } from "./common";
|
||||
|
||||
// A middleware has to be a function of type Middleware
|
||||
const prettyError: Middleware = async (request, env, _ctx, middlewareCtx) => {
|
||||
try {
|
||||
const response = await middlewareCtx.next(request, env);
|
||||
return response;
|
||||
} catch (e: any) {
|
||||
const html = `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Error 🚨</title>
|
||||
<style>
|
||||
pre {
|
||||
margin: 16px auto;
|
||||
max-width: 600px;
|
||||
background-color: #eeeeee;
|
||||
border-radius: 4px;
|
||||
padding: 16px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<pre>${e.stack}</pre>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
return new Response(html, {
|
||||
status: 500,
|
||||
headers: { "Content-Type": "text/html;charset=utf-8" },
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default prettyError;
|
||||
Loading…
Add table
Add a link
Reference in a new issue