File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
packages/nextjs/src/config/templates Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,16 @@ const serverComponent = serverComponentModule.default;
2727
2828let wrappedServerComponent ;
2929if ( typeof serverComponent === 'function' ) {
30- // TODO: explain why this code needs to be in this file
30+ // For some odd Next.js magic reason, `headers()` will not work if used inside `wrapServerComponentsWithSentry`.
31+ // Current assumption is that Next.js applies some loader magic to userfiles, but not files in node_modules. This file
32+ // is technically a userfile so it gets the loader magic applied.
3133 wrappedServerComponent = new Proxy ( serverComponent , {
3234 apply : ( originalFunction , thisArg , args ) => {
3335 let sentryTraceHeader : string | undefined = undefined ;
3436 let baggageHeader : string | undefined = undefined ;
3537
38+ // If we call the headers function inside the build phase, Next.js will automatically mark the server component as
39+ // dynamic(SSR) which we do not want in case the users have a static component.
3640 if ( process . env . NEXT_PHASE !== 'phase-production-build' ) {
3741 const headersList = headers ( ) ;
3842 sentryTraceHeader = headersList . get ( 'sentry-trace' ) ;
You can’t perform that action at this time.
0 commit comments