Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@sentry/node] Error URL doesn't include port number in Express #1917

Closed
DanielGibbsNZ opened this issue Feb 20, 2019 · 6 comments
Closed

[@sentry/node] Error URL doesn't include port number in Express #1917

DanielGibbsNZ opened this issue Feb 20, 2019 · 6 comments

Comments

@DanielGibbsNZ
Copy link

Package + Version

  • @sentry/node: 4.6.2

Description

The request URL (event.request.url) added by the Sentry.Handlers.requestHandler does not include the port. Looking at the source shows that it derives the URL from the hostname, which in Express is retrieved from req.hostname (which doesn't contain the port) rather than headers.host (which does).

This can be seen by running an Express server on a non-default port (e.g. 8080) and performing an HTTP request to https://example.com:8080/error which causes an error. The error shown in Sentry shows the URL as https://example.com/error.

@kamilogorek
Copy link
Contributor

Feel free to introduce a PR for this change, will be more than happy to merge it :)

@DanielGibbsNZ
Copy link
Author

Would it be an acceptable solution to always use req.headers.host for the hostname first and then fall back to the express and koa fields?

@kamilogorek
Copy link
Contributor

Yes, as hostname is derived from it anyway – https://expressjs.com/en/api.html#req.hostname

Contains the hostname derived from the Host HTTP header.

However, we want to add port only if it's not a default (80 for https, 8000 for https).

@DanielGibbsNZ
Copy link
Author

Regarding contributing: I forked the repository and followed the instructions in CONTRIBUTING.md but when I run yarn build in the packages/node directory I get a ton of TypeScript errors, most of which are something like Cannot find module '@sentry/types'. Is there some additional setup I need to do to be able to build the package?

@HazAT
Copy link
Member

HazAT commented Apr 4, 2019

@DanielGibbsNZ Sorry, you need to run yarn build in the root once to have everything in place. Then yarn build in node should work.

@kamilogorek
Copy link
Contributor

Closing the issue as a part of large repository cleanup, due to it being inactive and/or outdated.
Please do not hesitate to ping me if it is still relevant, and I will happily reopen and work on it.
Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants