feathers
feathers copied to clipboard
Socket 404 Handler
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.
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?
There is currently not but it might be a good idea to be able to add some kind of middleware.