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
when returning a Response object from the middleware, the headers and body get mixed up, if both the middleware returns a Promise and the file router returns a webpage. (Or if multiple middleware return Responses)
Expected behavior 🤔
Only one of the Responses should be used, instead of mixing mutliple responses together. The middleware response should have priority, and only if no Response is returned, the webpage should try to render.
Steps to reproduce 🕹
Steps:
create a routes/[...404].js error page
create a middleware, that returns a new Response("some content"), when accessing a specific page
check in browser, what gets returned. Sometimes it returns "some content", other times "<!DOCTYPE ht" (the start from the 404 error page, with same length as the "some content" string from the middleware)
Context 🔦
I was trying to create a file server, that returns files from the middleware, and directory listings via solid routes.
The problem lies in packages/start/src/middleware/index.tsx, as sendWebResponse is not awaited in any of the wrap* functions, and createMiddleware also doesn't await properly, if an array is passed in.
works, but inspecting the 302 response shows that the page body was rendered and streamed.
Using the sendWebResponse workaround doesn't seem to change this behavior.
Update: After some more testing I think this is already working as expected. The response body for the redirect is only displayed in Firefox and identical to the actual response after the redirect (including a random nonce generated server-side). This is probably a Bug/Feature of the Firefox DevTools.
peterhirn
added a commit
to phi-ag/solid-pages
that referenced
this issue
Nov 5, 2024
Duplicates
Latest version
Current behavior 😯
when returning a Response object from the middleware, the headers and body get mixed up, if both the middleware returns a Promise and the file router returns a webpage. (Or if multiple middleware return Responses)
Expected behavior 🤔
Only one of the Responses should be used, instead of mixing mutliple responses together. The middleware response should have priority, and only if no Response is returned, the webpage should try to render.
Steps to reproduce 🕹
Steps:
Context 🔦
I was trying to create a file server, that returns files from the middleware, and directory listings via solid routes.
The problem lies in packages/start/src/middleware/index.tsx, as sendWebResponse is not awaited in any of the wrap* functions, and createMiddleware also doesn't await properly, if an array is passed in.
As a workaround, i currently do
instead of
in my project.
Your environment 🌎
No response
The text was updated successfully, but these errors were encountered: