File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
docs/platforms/javascript/common/troubleshooting Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,37 @@ class HomeController < ApplicationController
195
195
end
196
196
```
197
197
198
+ ``` javascript
199
+ const SENTRY_HOST = " oXXXXXX.ingest.sentry.io"
200
+ const SENTRY_PROJECT_IDS = [" 123456" ]
201
+
202
+ export const postAction = async ({ request }) => {
203
+ try {
204
+ const envelope = await request .text ();
205
+ const piece = envelope .split (" \n " )[0 ];
206
+ const header = JSON .parse (piece);
207
+ const dsn = new URL (header[" dsn" ]);
208
+ const project_id = dsn .pathname ? .replace (" /" , " " );
209
+
210
+ if (dsn .hostname !== SENTRY_HOST ) {
211
+ throw new Error (` Invalid sentry hostname: ${ dsn .hostname } ` );
212
+ }
213
+
214
+ if (! project_id || ! SENTRY_PROJECT_IDS .includes (project_id)) {
215
+ throw new Error (` Invalid sentry project id: ${ project_id} ` );
216
+ }
217
+
218
+ const upstream_sentry_url = ` https://${ SENTRY_HOST } /api/${ project_id} /envelope/` ;
219
+ await fetch (upstream_sentry_url, { method: " POST" , body: envelope });
220
+
221
+ return json ({}, { status: 200 });
222
+ } catch (e) {
223
+ console .error (" error tunneling to sentry" , e);
224
+ return json ({ error: " error tunneling to sentry" }, { status: 500 });
225
+ }
226
+ };
227
+ ` ` `
228
+
198
229
If your use-case is related to the SDK package itself being blocked, any of the following solutions will help you resolve this issue.
199
230
200
231
### Using the NPM Package
You can’t perform that action at this time.
0 commit comments