mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
e48eb5a2a9
### 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`
20 lines
399 B
TypeScript
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',
|
|
},
|
|
})
|
|
}
|