-
-
Couldn't load subscription status.
- Fork 61
Description
Problem summary
sirv responds to HTTP requests other than GET, thereby masking those routes (e.g., POST) on Polka servers as it is global middleware. It also responds to WebSocket upgrade requests so if a static route (e.g., /echo/index.html) and a WebSocket route (e.g., /echo) share the same route, it prevents the WebSocket route from being called.
Example
I have a Polka server that uses sirv to serve the static folder:
static
╰ echo
╰ index.html
I also have a POST route and a WebSocket route on /echo. I make the following requests:
- A
GETrequest to/echo - A
POSTrequest to/echo - A WebSocket request to
/echo
What happens
sirv responds to all requests to /echo with the static page regardless of HTTP method or whether or not the GET request is a WebSocket upgrade request.
What should happen
sirv should ignore all requests methods other than GET requests that are not WebSocket upgrade requests. In all other cases, it should call next() (or return a not found status if there isn’t a next middleware).