Repository: getsentry/sentry

Issue:
endpoint in error-page-embed.js does not respect system.url-prefix
## Important Details

How are you running Sentry?

* [x ] On-Premise docker [9.1.1]
## Description

using raven-js with angular works as expected to capture exceptions.
when reporting errors we get the wrong endpoint from the sentry instance

javascript snippet:
```js
Raven
  .config(`https://${environment.sentryKey}@MY_INSTANCE/PROJECT_NUMBER`,
    {
      environment: environment.production ? 'prod' : 'dev',
      release: versions.version
    }
  )
  .install();

export class RavenErrorHandler implements ErrorHandler {
  handleError(error: any): void {
    const err = error.originalError || error;
    console.error(err);
    Raven.captureException(err);
    if (true) {
      // fetches error-page-embed.js from sentry instance with wrong endpoint (docker endpoint)
      Raven.showReportDialog();
    }
  }
}
```

this end point is set here: https://github.com/getsentry/sentry/blob/master/src/sentry/web/frontend/error_page_embed.py
```python
# using request.build_absolute_uri() instead of the value of system.url-prefix 'endpoint':  
 
mark_safe('*/' + json.dumps(request.build_absolute_uri()) + ';/*'),
```

## Steps to Reproduce

web:9000 is the hostname of the docker container
![screenshot3](https://user-images.githubusercontent.com/1331762/61046390-4c9d7c00-a3dd-11e9-9554-0ab5b09c72d2.png)

### What you expected to happen

system.url-prefix in config.yaml: error-page-embed.js should be respected


cc/ @max-wittig



Discussion:
This was a bug in the initial setup screen in 9.1.1 which was fixed in 9.1.2 now. If you set the `system.url-prefix` yourself afterward, this should go away.

Are you able to try this and also 9.1.2 just in case?
@BYK we just tried this with 9.1.2 but unfortunately the error still persist even if we set the `system.url-prefix` correctly.

The URI is build using the Django request method `build_absolute_uri()` which returns the hostname of the Docker container instead of the configured system URL.
@deveaud-m - ah, sorry. I'll look into this as soon as possible. Thanks for trying 9.1.2 :)

Resolving patch:
diff --git a/src/sentry/web/frontend/error_page_embed.py b/src/sentry/web/frontend/error_page_embed.py
--- a/src/sentry/web/frontend/error_page_embed.py
+++ b/src/sentry/web/frontend/error_page_embed.py
@@ -17,7 +17,7 @@
 from sentry.web.helpers import render_to_response
 from sentry.signals import user_feedback_received
 from sentry.utils import json
-from sentry.utils.http import is_valid_origin, origin_from_request
+from sentry.utils.http import absolute_uri, is_valid_origin, origin_from_request
 from sentry.utils.validators import normalize_event_id
 
 GENERIC_ERROR = _("An unknown error occurred while submitting your report. Please try again.")
@@ -208,7 +208,9 @@ def dispatch(self, request):
         )
 
         context = {
-            "endpoint": mark_safe("*/" + json.dumps(request.build_absolute_uri()) + ";/*"),
+            "endpoint": mark_safe(
+                "*/" + json.dumps(absolute_uri(request.get_full_path())) + ";/*"
+            ),
             "template": mark_safe("*/" + json.dumps(template) + ";/*"),
             "strings": json.dumps_htmlsafe(
                 {


Test patch: