You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm creating a middleware that logs the request and format it to corresponding status range. (example 400 - 499). the <HttpStatusCode code={404} /> works fine and it resolves to the correct status code.
however, in the middleware part. it always return 200
Expected behavior 🤔
it should reflect 404 for both middleware and to the final response. i assume that the problem lies to the middleware itself. createMiddleware has two parameters, onRequest and onBeforeResponse. it doesn't catch the final response before sending it the user. i assume this is the normal flow of the request cycle. it doesn't catch any status code that the developer put before sending the final request to the client. correct me if i'm wrong.
flowchart LR
user --> onRequest --> server --> onBeforeResponse --> solid-start --> user
Loading
i found this issue on vinxi that has somewhat the same problem as mine nksaraf/vinxi#182 but haven't fixed yet for months now.
Steps to reproduce 🕹
Steps:
create solid-start project
create a middleware.ts in ./src directory and place the path in app.config.ts
create a middleware for logging
import{createMiddleware}from"@solidjs/start/middleware";importtype{FetchEvent}from"@solidjs/start/server";asyncfunctionloggingMiddleware(event: FetchEvent){conststatus=event.response.status||0;if(status>=200&&status<=399){console.log(`${event.clientAddress} - ${event.request.method} - ${event.request.url} Status ${event.response.status}`);}if(status>=400&&status<=499){console.warn(`${event.clientAddress} - ${event.request.method} - ${event.request.url} Status ${event.response.status}`);}return;}exportdefaultcreateMiddleware({// uncomment it to see// onRequest: [loggingMiddleware],onBeforeResponse: [loggingMiddleware],});
Duplicates
Latest version
Current behavior 😯
Hi, I'm creating a middleware that logs the request and format it to corresponding status range. (example 400 - 499). the
<HttpStatusCode code={404} />works fine and it resolves to the correct status code.however, in the middleware part. it always return 200
Expected behavior 🤔
it should reflect 404 for both middleware and to the final response. i assume that the problem lies to the middleware itself.
createMiddlewarehas two parameters, onRequest and onBeforeResponse. it doesn't catch the final response before sending it the user. i assume this is the normal flow of the request cycle. it doesn't catch any status code that the developer put before sending the final request to the client. correct me if i'm wrong.flowchart LR user --> onRequest --> server --> onBeforeResponse --> solid-start --> useri found this issue on vinxi that has somewhat the same problem as mine nksaraf/vinxi#182 but haven't fixed yet for months now.
Steps to reproduce 🕹
Steps:
<HttpStatusCode code={404} />to *404.tsContext 🔦
No response
Your environment 🌎