Question about ReturnOverrides


So I’m still testing around to try and find what would be the best fit for our application since we need a potent middleware. So far I think gRPC will be the way to go, no complicated installation in Tyk and it leverages the full potential of the language we will choose.

I just have a quick question about ReturnOverrides.
I created this small middleware :
`const postMiddleware = (obj, callback) => {
var req = obj.request

// req is the coprocess.MiniRequestObject, we inject a header using the "set_headers" field:
req.set_headers = {
    'mycustomheader': 'post'

req.return_overrides = {
    response_code: 200,
    response_error: JSON.stringify({"test":"value"}),
    headers: {
        'myresponseheader': 'value'

// Use this callback to finish the operation, sending back the modified object:
callback(null, obj)


Works well but I noticed the calls to the related API are no longer shown in the Log browser of my Dashboard. I believe it is because using ReturnOverrides stops the request flow. But is there a way to still have the data in the logs ? If not yet possible, that would be nice to have :slight_smile:

Last thing, I think there might be an error in the documentation
It says “The ReturnOverrides object, when returned as part of a Coprocess.Object” but the ReturnOverrides is part of the MiniRequestObject. Maybe it’s written that way because Coprocess.MiniRequestObject is part of Coprocess.Object but I found it confusing.

Anyway, thanks !

Hi Robert,

That’s a valid point - ReturnOverrides was designed to trigger errors and it bypasses the analytics middleware, something we’ll need to addresss. Want to add an issue to our GitHub tracker for both of these bugs?

The tracker is here:

Done !

Thanks a lot for you feedback :slight_smile: