Skip to content

Commit f3ba304

Browse files
committed
Response.json
1 parent 9484442 commit f3ba304

1 file changed

Lines changed: 22 additions & 26 deletions

File tree

packages/start/src/config/nitroPlugin.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,14 @@ export function nitroPlugin(
6868
if (
6969
getHeader(event, "content-type")?.includes("application/json")
7070
) {
71-
return new Response(
72-
JSON.stringify(
73-
{
74-
status: 500,
75-
error: "Internal Server Error",
76-
message:
77-
"An unexpected error occurred. Please try again later.",
78-
timestamp: new Date().toISOString(),
79-
},
80-
null,
81-
2,
82-
),
71+
return Response.json(
72+
{
73+
status: 500,
74+
error: "Internal Server Error",
75+
message:
76+
"An unexpected error occurred. Please try again later.",
77+
timestamp: new Date().toISOString(),
78+
},
8379
{
8480
status: 500,
8581
headers: {
@@ -91,25 +87,25 @@ export function nitroPlugin(
9187

9288
return new Response(
9389
`
94-
<!DOCTYPE html>
95-
<html lang="en">
96-
<head>
97-
<meta charset="UTF-8" />
98-
<title>Error</title>
99-
<script type="module">
100-
import { ErrorOverlay } from '/@vite/client'
101-
document.body.appendChild(new ErrorOverlay(${JSON.stringify(
90+
<!DOCTYPE html>
91+
<html lang="en">
92+
<head>
93+
<meta charset="UTF-8" />
94+
<title>Error</title>
95+
<script type="module">
96+
import { ErrorOverlay } from '/@vite/client'
97+
document.body.appendChild(new ErrorOverlay(${JSON.stringify(
10298
prepareError(
10399
event.node.req,
104100
e,
105101
),
106102
).replace(/</g, "\\u003c")}))
107-
</script>
108-
</head>
109-
<body>
110-
</body>
111-
</html>
112-
`,
103+
</script>
104+
</head>
105+
<body>
106+
</body>
107+
</html>
108+
`,
113109
{
114110
status: 500,
115111
headers: {

0 commit comments

Comments
 (0)