Empty body in Docker private registry notifications request to listener?

Hey,

I have setup a private registry v2 which is running inside a container and also setup a notification listener for it, which is written in nodejs. But the problem is that notification request body is always empty and i am not able to figure out the problem .
So any suggestion or help would be really helpful.

Thanks in advance

Were you able to figure this out ?

I found the cause

if the application is node js then the data send by the registry is received as a buffer. All you should do is convert it back to String

Assuming that you have asked the private registry notification listener to send notification to the /notification url

Here is an example

app.post("/notification", function(req, res) {
    //If you use req.body it will print empty flower brackets
    console.log(req.body); // this will print empty {}
    //Instead use the below
    req.on(‘data’, function(data) { // data here is buffer
        console.log(data.toString(‘utf8’);
    });
    res.sendStatus(200);
});

1 Like

great resolve my issue thanks bro same problem with express node