Closed remi-freriks closed 11 months ago
I cannot determine the cause of the error, but you can change the Sentry settings via toucanOptions
in serverInit
.
beforeSend
Hooks should be able to be used to ignore errors on specific paths.
For example
// hooks.server.ts
import { serverInit } from '@jill64/sentry-sveltekit-cloudflare'
const { onHandle, onError } = serverInit(
'__SENTRY_DSN__',
{
toucanOptions: {
beforeSend: (event) => {
const { request } = event
const url = new URL(request?.url ?? '')
if (request?.method === 'POST' && url.pathname === '/ignore/path') {
// Errors are not sent to sentry.
return null
}
return event
}
}
}
)
export const handle = onHandle()
export const handleError = onError()
Thanks for your solution. I added it to my web application. As long as we are not yet in Sentry's business plan where we can ignore errors, this is a nice solution
How can I ignore an error for a specific paths in hooks.server.ts?
A bit of background information: I am currently getting a lot of errors in sentry where POST requests are made to xmlrpc.php (wordpress exploit). I use action named routes. Errors occur because I have no default action (No action with name 'default' found). Unfortunately, this is not possible if you use action named routes (https://kit.svelte.dev/docs/form-actions#named-actions).