-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Package: nextjsIssues related to the Sentry Nextjs SDKIssues related to the Sentry Nextjs SDK
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/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/nextjs
SDK Version
7.23.0
Framework Version
13.0.6-canary.3
Link to Sentry event
No response
Steps to Reproduce
- a next config
// next.config.js
import { withSentryConfig } from "@sentry/nextjs";
const rewrites = async () => {
const apiUrl = process.env.API_URL.trim();
if (!(process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN)) {
throw new Error("process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN must be defined");
}
const sentryUrl = new URL(process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN);
const sentryProjectId = sentryUrl.pathname.replace("/", "");
sentryUrl.pathname = `/api/${sentryProjectId}/envelope/`;
const sentryProxyURL = sentryUrl.toString();
return [
{
source: "/:path*",
destination: "/:path*",
},
{
source: "/sentry",
destination: sentryProxyURL,
basePath: false,
},
];
};
const moduleExports = {
rewrites,
reactStrictMode: true,
};
const SentryWebpackPluginOptions = {
silent: true,
};
export default withSentryConfig(moduleExports, SentryWebpackPluginOptions);
- run
next build
Expected Result
It should build correctly.
Actual Result
next build
info - Loaded env from .env.local
info - Skipping validation of types
info - Linting
info - Creating an optimized production build
info - Compiled successfully
info - Collecting page data ..TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:387:5)
at URL.onParseError (node:internal/url:565:9)
at new URL (node:internal/url:641:5)
at Object.makeNodeTransport [as transport] (/node_modules/@sentry/node/cjs/transports/http.js:34:23)
at new BaseClient (/node_modules/@sentry/core/cjs/baseclient.js:70:33)
at new NodeClient (/node_modules/@sentry/node/cjs/client.js:44:5)
at Object.initAndBind (/node_modules/@sentry/core/cjs/sdk.js:34:18)
at Object.init (/node_modules/@sentry/node/cjs/sdk.js:159:8)
at Object.init (/node_modules/@sentry/nextjs/cjs/index.server.js:69:8)
at Object.9673 (/.next/server/chunks/290.js:19:45) {
input: '/sentry',
code: 'ERR_INVALID_URL'
}
> Build error occurred
Error: Failed to collect page data for /homepage
at /node_modules/next/dist/build/utils.js:959:15
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
type: 'Error'
}
Metadata
Metadata
Assignees
Labels
Package: nextjsIssues related to the Sentry Nextjs SDKIssues related to the Sentry Nextjs SDK