colyseus / uWebSockets-express

Express API compatibility layer for uWebSockets.js
https://npmjs.com/package/uwebsockets-express
MIT License
56 stars 13 forks source link

Sending status code is not working #12

Closed JCMais closed 2 years ago

JCMais commented 3 years ago

Hi, first, thanks for this library! It is really helpful.

I found a possible issue when using the library, it seems that a route like this one:

    app.get('/test', (_req, res) => {
        return res.status(401).send()
    })

Is not sending the 401 status to the client.

I found this when trying to use this with express-basic-auth.

Using res.res.writeStatus(401).end() does work, but that means accessing the internal uWS Response object.

Another possible issue is that handlers created with router.post are also handling get requests:

router.get('/subpath', ...) // this also handles post requests - not just get
app.use('/path', router)
endel commented 2 years ago

Just published uwebsockets-express@1.2.0 with these changes https://github.com/colyseus/uWebSockets-express/pull/13 (now the built-in express router is being used rather than being mocked/mimicked)

JCMais commented 2 years ago

Thanks for getting this fixed @endel! 🚀