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
Last week I wanted to add websocket to an existing nitro app, but ran into some unexpected behaviours. I think fixing/improving these would be beneficial for everyone.
I have two main parts of my api /public/* and /protected/*. There is a middleware registered, that is authenticating the user on every /protected/* route and also adds the user object to event.context.
My plan was simple, create a /protected/ws.ts route, that is using definedEventHandler. This way (in my plan) I wouldn't need to duplicate the authentication logic and everything should work nicely. This is sadly not the case.
middlewares do not run for websocket routes. I think this sohuld be treated as a bug and kinda serious imo.
there is no way to access the event, or event.context in defineWebsocketHandler's upgrade callback. This means that even if middlewares did run, the result could not reach the websocket handler.
Additional information
Would you be willing to help implement this feature?
The text was updated successfully, but these errors were encountered:
Describe the feature
Last week I wanted to add websocket to an existing nitro app, but ran into some unexpected behaviours. I think fixing/improving these would be beneficial for everyone.
I have two main parts of my api
/public/*
and/protected/*
. There is amiddleware
registered, that is authenticating the user on every /protected/* route and also adds the user object toevent.context
.My plan was simple, create a
/protected/ws.ts
route, that is using definedEventHandler. This way (in my plan) I wouldn't need to duplicate the authentication logic and everything should work nicely. This is sadly not the case.Additional information
The text was updated successfully, but these errors were encountered: