Skip to content

Commit 9218eaa

Browse files
author
Luca Forstner
authored
fix(nextjs): Restore autoInstrumentMiddleware functionality (#9323)
1 parent c5c12a9 commit 9218eaa

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,20 @@ export function constructWebpackConfigFunction(
243243
});
244244

245245
// Wrap middleware
246-
newConfig.module.rules.unshift({
247-
test: isMiddlewareResource,
248-
use: [
249-
{
250-
loader: path.resolve(__dirname, 'loaders', 'wrappingLoader.js'),
251-
options: {
252-
...staticWrappingLoaderOptions,
253-
wrappingTargetKind: 'middleware',
246+
if (userSentryOptions.autoInstrumentMiddleware ?? true) {
247+
newConfig.module.rules.unshift({
248+
test: isMiddlewareResource,
249+
use: [
250+
{
251+
loader: path.resolve(__dirname, 'loaders', 'wrappingLoader.js'),
252+
options: {
253+
...staticWrappingLoaderOptions,
254+
wrappingTargetKind: 'middleware',
255+
},
254256
},
255-
},
256-
],
257-
});
257+
],
258+
});
259+
}
258260
}
259261

260262
if (isServer && userSentryOptions.autoInstrumentAppDirectory !== false) {

0 commit comments

Comments
 (0)