Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only handle GET requests that are not WebSocket requests #127

Open
aral opened this issue Jan 16, 2022 · 0 comments · May be fixed by #128
Open

Only handle GET requests that are not WebSocket requests #127

aral opened this issue Jan 16, 2022 · 0 comments · May be fixed by #128

Comments

@aral
Copy link

aral commented Jan 16, 2022

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant