aws / aws-xray-sdk-node

The official AWS X-Ray SDK for Node.js.
Apache License 2.0
271 stars 155 forks source link

Bug in generation of the http.url #455

Closed ocdinvstr closed 3 years ago

ocdinvstr commented 3 years ago

Line below in the "aws-xray-sdk-core/dist/lib/middleware/incoming_request_data.js" is generating url wrong. When concatenating the req.host and req.url it's eating up the backslash between host and url and generating url as "https://xyz.domain.comapicall" instead of "https://xyz.domain.com/apicall" and all the service endpoints are being stored and displayed wrong on X-Ray side.

        url = ((req.connection.secure || req.connection.encrypted) ? 'https://' : 'http://') +
            ((req.headers['host'] || '') + (req.url || ''));
willarmiros commented 3 years ago

According to the Node documentation, req.url should generally begin with a slash. Do you have a reproduction case where this malformed URL is being produced?

ocdinvstr commented 3 years ago

Right, in the case, some custom library added to Restify as plugin is removing it.

ocdinvstr commented 3 years ago

Thanks for the help @willarmiros, it's my mistake not to look at other codes in the project first, but if you consider this for the next releases, even it's done by other code library, it would be good.