born05 / craft-sentry

Pushes Craft CMS errors to Sentry.
MIT License
9 stars 11 forks source link

Sentry URL tag values are invalid URLs #25

Closed jamesmacwhite closed 2 years ago

jamesmacwhite commented 2 years ago

When using the Sentry SDK plugin, the URL tag value for an event is including the plain HTTP port value in the URL. This is invalid as it's a TLS connection with plain HTTP port 80.

Example:

image

A URL of https://example.com:80, will never be valid.

Doing some investigation this seems to be potentially from the SERVER_PORT in PHP. However I contacted Sentry about this and they said it likely relates to the hosting environment/reverse proxy, so it might not be an issue with this plugin either but currently all the URL values are invalid.

I even tested this on local dev which also uses a Docker setup with proxying and this had URLs with https://example.com:8080 and SERVER_PORT was 8080, so it seems like this is where the issue is, but how you can actually override it or fix it I'm not sure.

jamesmacwhite commented 2 years ago

I ended up finding this was due to reverse proxying. I had to override the PHP SERVER_PORT value with the X-FORWARDED-PORT value from our environment. It would seem Sentry uses SERVER_PORT by default.