feathers icon indicating copy to clipboard operation
feathers copied to clipboard

Socket 404 Handler

Open ultm8m opened this issue 5 years ago • 2 comments

I'm looking to change the response of the Feathers error handler for an erroneous socket request.

Adding a handler to apps.hooks.js works for sockets if the service exists and there is an error, but i'm looking to handle the error if the service does not exist.

Socket Response to non-existent service

Socket responds with: 431[{"name":"NotFound","message":"Service '<script>alert("test")</script>' not found","code":404,"className":"not-found","errors":{}}]

I'd like to change the default error handler to remove the message.

ultm8m avatar Mar 06 '20 17:03 ultm8m

I found where the error is throw from: @feathersjs/transports-commons/lib/socket/utils.js, Line 70 return Promise.reject(new errors_1.default.NotFound(`Service '${path}' not found`));

https://github.com/feathersjs/feathers/blob/master/packages/transport-commons/src/socket/utils.ts#L84

Is there a way to override this within the Feathers app?

ultm8m avatar Mar 06 '20 20:03 ultm8m

There is currently not but it might be a good idea to be able to add some kind of middleware.

daffl avatar Mar 09 '20 17:03 daffl