Skip to content

Commit 7e57cb7

Browse files
authored
fix(nextjs): Make api route identifier stricter (#7126)
1 parent ef16ad5 commit 7e57cb7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function constructWebpackConfigFunction(
9696
appDirPath = path.join(projectDir, 'src', 'app');
9797
}
9898

99-
const apiRoutesPath = path.join(pagesDirPath, 'api');
99+
const apiRoutesPath = path.join(pagesDirPath, 'api', '/');
100100

101101
const middlewareJsPath = path.join(pagesDirPath, '..', 'middleware.js');
102102
const middlewareTsPath = path.join(pagesDirPath, '..', 'middleware.ts');

packages/nextjs/test/config/loaders.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ describe('webpack loaders', () => {
118118
resourcePath: '/Users/Maisey/projects/squirrelChasingSimulator/src/pages/[...testPage].js',
119119
expectedWrappingTargetKind: 'page',
120120
},
121+
// Regression test for https://github.com/getsentry/sentry-javascript/issues/7122
122+
{
123+
resourcePath: '/Users/Maisey/projects/squirrelChasingSimulator/src/pages/apidoc/[version].tsx',
124+
expectedWrappingTargetKind: 'page',
125+
},
121126
{
122127
resourcePath: '/Users/Maisey/projects/squirrelChasingSimulator/src/middleware.js',
123128
expectedWrappingTargetKind: 'middleware',

0 commit comments

Comments
 (0)