Skip to content

Commit 59d5554

Browse files
authored
fix(nextjs): Fix devserver CORS blockage when assetPrefix is defined (#9766)
1 parent 1eb2ded commit 59d5554

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/nextjs/src/client/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,17 @@ function addClientIntegrations(options: BrowserOptions): void {
113113
if (hasTracingEnabled(options)) {
114114
const defaultBrowserTracingIntegration = new BrowserTracing({
115115
// eslint-disable-next-line deprecation/deprecation
116-
tracingOrigins: [...defaultRequestInstrumentationOptions.tracingOrigins, /^(api\/)/],
116+
tracingOrigins:
117+
process.env.NODE_ENV === 'development'
118+
? [
119+
// Will match any URL that contains "localhost" but not "webpack.hot-update.json" - The webpack dev-server
120+
// has cors and it doesn't like extra headers when it's accessed from a different URL.
121+
// TODO(v8): Ideally we rework our tracePropagationTargets logic so this hack won't be necessary anymore (see issue #9764)
122+
/^(?=.*localhost)(?!.*webpack\.hot-update\.json).*/,
123+
/^\/(?!\/)/,
124+
]
125+
: // eslint-disable-next-line deprecation/deprecation
126+
[...defaultRequestInstrumentationOptions.tracingOrigins, /^(api\/)/],
117127
routingInstrumentation: nextRouterInstrumentation,
118128
});
119129

0 commit comments

Comments
 (0)