Chris, the 0.5x engineer
Chris, the 0.5x engineer
SSolidJS
Created by Chris, the 0.5x engineer on 5/8/2024 in #support
OnMount fired twice for the same component
No description
30 replies
SSolidJS
Created by Chris, the 0.5x engineer on 12/27/2023 in #support
[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
},
],
});
1 replies