Title: `ERR_INVALID_URL` for next config rewrite option · Issue #6381 · getsentry/sentry-javascript · GitHub
Open Graph Title: `ERR_INVALID_URL` for next config rewrite option · Issue #6381 · getsentry/sentry-javascript
X Title: `ERR_INVALID_URL` for next config rewrite option · Issue #6381 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/6381
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`ERR_INVALID_URL` for next config rewrite option","articleBody":"### Is there an existing issue for this?\n\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [X] I have reviewed the documentation https://docs.sentry.io/\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which package are you using?\n\n@sentry/nextjs\n\n### SDK Version\n\n7.23.0\n\n### Framework Version\n\n13.0.6-canary.3\n\n### Link to Sentry event\n\n_No response_\n\n### Steps to Reproduce\n\n1. a next config\r\n```javascript\r\n// next.config.js\r\nimport { withSentryConfig } from \"@sentry/nextjs\";\r\n\r\nconst rewrites = async () => {\r\n const apiUrl = process.env.API_URL.trim();\r\n if (!(process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN)) {\r\n throw new Error(\"process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN must be defined\");\r\n }\r\n const sentryUrl = new URL(process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN);\r\n const sentryProjectId = sentryUrl.pathname.replace(\"/\", \"\");\r\n sentryUrl.pathname = `/api/${sentryProjectId}/envelope/`;\r\n const sentryProxyURL = sentryUrl.toString();\r\n return [\r\n {\r\n source: \"/:path*\",\r\n destination: \"/:path*\",\r\n },\r\n {\r\n source: \"/sentry\",\r\n destination: sentryProxyURL,\r\n basePath: false,\r\n },\r\n ];\r\n};\r\n\r\nconst moduleExports = {\r\n rewrites,\r\n reactStrictMode: true,\r\n};\r\n\r\nconst SentryWebpackPluginOptions = {\r\n silent: true,\r\n};\r\nexport default withSentryConfig(moduleExports, SentryWebpackPluginOptions);\r\n\r\n```\r\n2. run `next build`\n\n### Expected Result\n\nIt should build correctly.\n\n### Actual Result\n\n```\r\nnext build\r\ninfo - Loaded env from .env.local\r\ninfo - Skipping validation of types\r\ninfo - Linting \r\ninfo - Creating an optimized production build \r\ninfo - Compiled successfully\r\ninfo - Collecting page data ..TypeError [ERR_INVALID_URL]: Invalid URL\r\n at new NodeError (node:internal/errors:387:5)\r\n at URL.onParseError (node:internal/url:565:9)\r\n at new URL (node:internal/url:641:5)\r\n at Object.makeNodeTransport [as transport] (/node_modules/@sentry/node/cjs/transports/http.js:34:23)\r\n at new BaseClient (/node_modules/@sentry/core/cjs/baseclient.js:70:33)\r\n at new NodeClient (/node_modules/@sentry/node/cjs/client.js:44:5)\r\n at Object.initAndBind (/node_modules/@sentry/core/cjs/sdk.js:34:18)\r\n at Object.init (/node_modules/@sentry/node/cjs/sdk.js:159:8)\r\n at Object.init (/node_modules/@sentry/nextjs/cjs/index.server.js:69:8)\r\n at Object.9673 (/.next/server/chunks/290.js:19:45) {\r\n input: '/sentry',\r\n code: 'ERR_INVALID_URL'\r\n}\r\n\r\n> Build error occurred\r\nError: Failed to collect page data for /homepage\r\n at /node_modules/next/dist/build/utils.js:959:15\r\n at processTicksAndRejections (node:internal/process/task_queues:96:5) {\r\n type: 'Error'\r\n}\r\n```","author":{"url":"https://github.com/Naddiseo","@type":"Person","name":"Naddiseo"},"datePublished":"2022-12-01T22:06:54Z","url":"https://github.com/getsentry/sentry-javascript/issues/6381"}
| 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:bcf48c18-62ce-4649-ec1f-5e748cde2ef4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6CA:35E323:BAB67D:1060A1C:6B0438F9 |
| html-safe-nonce | a01361be904649b3f548b2bf11e38f4afbd11e1b813f26c3000d450711293bfc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkNBOjM1RTMyMzpCQUI2N0Q6MTA2MEExQzo2QjA0MzhGOSIsInZpc2l0b3JfaWQiOiIyNzQ1MzU4NDg5NTQwNTA4MDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 44967fe2a314286838298269c8f52b08a45f8ecf15c91f157f04e6f988299733 |
| hovercard-subject-tag | issue:1472021495 |
| 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/6381/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1defe963bb05dec000ce92f1386ca538e905f6edbf322072fdb9a73baaa97b8b/getsentry/sentry-javascript/issues/6381 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1defe963bb05dec000ce92f1386ca538e905f6edbf322072fdb9a73baaa97b8b/getsentry/sentry-javascript/issues/6381 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Naddiseo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| 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 | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| 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