Files
vercel__next.js/test/e2e/on-request-error/basic/instrumentation.ts
Jiachi Liu e48eb5a2a9 Drop the experimental env var for onRequestError API (#67856)
### What

Since the API is getting more stablized with few past iteration and it's
still under the experimental flag, it's good to ship as a API along with
the `instrumentation.js`
2024-07-17 22:27:14 +02:00

20 lines
399 B
TypeScript

import { type Instrumentation } from 'next'
export const onRequestError: Instrumentation.onRequestError = (
err,
request,
context
) => {
fetch(`http://localhost:${process.env.PORT}/write-log`, {
method: 'POST',
body: JSON.stringify({
message: (err as Error).message,
request,
context,
}),
headers: {
'Content-Type': 'application/json',
},
})
}