Skip to content

Only handle GET requests that are not WebSocket requests #127

@aral

Description

@aral

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 GET request to /echo
  • A POST request 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions