how to end response without using "nativeEvent"?

what would be a better way of writing the following inside of middleware?
 event.nativeEvent.res.writeHead(403).end();
 return;
 event.nativeEvent.res.writeHead(403).end();
 return;
Returning a new Response() gives a type error (but works as expected) and just setting the event.response.status and returning doesn't end the response
2 Replies
Raqueebuddin Aziz
What's the type error? As returning early is the way to end early
victornswd
victornswdOP10mo ago
onRequest from createMiddleware gives: Type '(event: FetchEvent) => Promise<Response | undefined>' is not assignable to type 'RequestMiddleware | RequestMiddleware[] | undefined'. just checked now, and throwing a new Response works as expected
Want results from more Discord servers?
Add your server