Title: Add tunneling option to @sentry/astro · Issue #10309 · getsentry/sentry-javascript · GitHub
Open Graph Title: Add tunneling option to @sentry/astro · Issue #10309 · getsentry/sentry-javascript
X Title: Add tunneling option to @sentry/astro · Issue #10309 · getsentry/sentry-javascript
Description: Problem Statement I think the Next package has an option for tunneling, it would be great to have the same for Astro Solution Brainstorm Back when I had a look at the docs, there was a snippet with how to create a tunnel endpoint in PHP....
Open Graph Description: Problem Statement I think the Next package has an option for tunneling, it would be great to have the same for Astro Solution Brainstorm Back when I had a look at the docs, there was a snippet with...
X Description: Problem Statement I think the Next package has an option for tunneling, it would be great to have the same for Astro Solution Brainstorm Back when I had a look at the docs, there was a snippet with...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/10309
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add tunneling option to @sentry/astro","articleBody":"### Problem Statement\n\nI think the Next package has an option for tunneling, it would be great to have the same for Astro\n\n### Solution Brainstorm\n\nBack when I had a look at the docs, there was a snippet with how to create a tunnel endpoint in PHP. Closest thing I find now is https://docs.sentry.io/platforms/javascript/troubleshooting/#using-the-tunnel-option.\r\n\r\nAnyway, it seems fairly easy with the `injectRoute` utility. Here is what I've done for a project of mine:\r\n\r\n```ts\r\n// src/pages/sy/[...params].ts\r\n\r\nimport type { APIContext } from \"astro\";\r\n\r\nexport const prerender = false;\r\n\r\nexport async function POST({ request }: APIContext) {\r\n const body = await request.text();\r\n\r\n let payload: {\r\n sent_at: string;\r\n sdk: { name: string; version: string };\r\n dsn: string;\r\n };\r\n\r\n try {\r\n payload = JSON.parse(body.split(\"\\n\")[0]);\r\n } catch (err) {\r\n console.error(err);\r\n return new Response(null, { status: 400 });\r\n }\r\n\r\n if (!payload.dsn) {\r\n return new Response(\"Invalid request\", { status: 400 });\r\n }\r\n\r\n const dsn = new URL(payload.dsn);\r\n const projectID = dsn.pathname.replace(/\\//g, \"\");\r\n\r\n if (projectID !== import.meta.env.SECRET_SENTRY_PROJECT_ID) {\r\n return new Response(\"Invalid request\", { status: 400 });\r\n }\r\n\r\n await fetch(`https://sentry.io/api/${projectID}/envelope/`, {\r\n method: \"POST\",\r\n headers: {\r\n \"Content-type\": \"application/x-sentry-envelope\",\r\n },\r\n body: JSON.stringify(payload),\r\n });\r\n\r\n return new Response(null, { status: 200 });\r\n}\r\n```\r\nIt's not always working so something is probably off. I can contribute this if you can help fix the endpoint logic itself","author":{"url":"https://github.com/florian-lefebvre","@type":"Person","name":"florian-lefebvre"},"datePublished":"2024-01-24T10:09:28Z","url":"https://github.com/getsentry/sentry-javascript/issues/10309"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9deba552-7054-8eaa-c0b2-6c98a1640b12 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ADBE:2F821:1A5BB9:23077B:6B04CC5E |
| html-safe-nonce | 4deb2d4e4a40e23080df03bcbe58a920392210e17a151b49b6f88da43af46642 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBREJFOjJGODIxOjFBNUJCOToyMzA3N0I6NkIwNENDNUUiLCJ2aXNpdG9yX2lkIjoiMTEzNDY4NjQxMDk5ODMzNjYwNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 12a11ad9599d817833521c4a3644b1b2bb3879e7542bdf2fbee774c413055abc |
| hovercard-subject-tag | issue:2097907057 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/10309/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d4d53c6e7cfda95dbefa5492548b4cae198a618b1f8e66f9d50d903191d10c10/getsentry/sentry-javascript/issues/10309 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d4d53c6e7cfda95dbefa5492548b4cae198a618b1f8e66f9d50d903191d10c10/getsentry/sentry-javascript/issues/10309 |
| og:image:alt | Problem Statement I think the Next package has an option for tunneling, it would be great to have the same for Astro Solution Brainstorm Back when I had a look at the docs, there was a snippet with... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | florian-lefebvre |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27ed421e5c2dac040a37529b5b9191edcc4a3de70521471e81fb4b4d9dc2aa7d |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 63dc19014c621c67306d7899c04c78dcd0d95803 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width