[Middleware] Confusion around onBeforeRequest hook

Hey team! I'm playing with the latest version of Solid start and noticed something that might be me, misunderstanding the doc. I'm having a middleware onBeforeResponse that is supposed to check the response content type and if it's HTML, modify the body to add some stuff in the <head> tag (think about a CSRF token for example). To do so, I'm using the hook onBeforeRequest. This hook gives me access to an event param and a response param. The response is empty, no body, no headers, nothing. If my hook just returns the response that was given, my site breaks. Can somebody tell me what this hook is supposed to do? Am I missing something? Thanks! Some code:
export default createMiddleware({
onRequest: [
(event) => {
console.log("GLOBAL", event.request.url);
},
],
onBeforeResponse: [
(event, response) => {
return response // <- doing this BREAKS EVERYTHIIIIIING
},
],
});
export default createMiddleware({
onRequest: [
(event) => {
console.log("GLOBAL", event.request.url);
},
],
onBeforeResponse: [
(event, response) => {
return response // <- doing this BREAKS EVERYTHIIIIIING
},
],
});
0 Replies
No replies yetBe the first to reply to this messageJoin