Skip to content

Commit

Permalink
fix middleware dev cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
annarhughes committed Jan 29, 2025
1 parent b7a13e6 commit ef188b6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
29 changes: 17 additions & 12 deletions app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,29 @@ export default async function RootLayout(props: RootLayoutProps) {
}
const messages = await getMessages();

// @ts-ignore
if (newrelic.agent?.collector.isConnected() === false) {
await new Promise((resolve) => {
// @ts-ignore
newrelic.agent.on('connected', resolve);
let browserTimingHeader = undefined;

if (process.env.NEXT_PUBLIC_ENV === 'production') {
// @ts-ignore
if (newrelic.agent?.collector.isConnected() === false) {
await new Promise((resolve) => {
// @ts-ignore
newrelic.agent.on('connected', resolve);
});
}
// @ts-ignore
browserTimingHeader = newrelic.getBrowserTimingHeader({
hasToRemoveScriptWrapper: true,
allowTransactionlessInjection: true,
});
}

// @ts-ignore
const browserTimingHeader = newrelic.getBrowserTimingHeader({
hasToRemoveScriptWrapper: true,
allowTransactionlessInjection: true,
});

return (
<RollbarProvider config={clientConfig}>
<html lang={locale} className={`${openSans.variable} ${montserrat.variable}`}>
<Script id="nr-browser-agent" dangerouslySetInnerHTML={{ __html: browserTimingHeader }} />
{browserTimingHeader && (
<Script id="nr-browser-agent" dangerouslySetInnerHTML={{ __html: browserTimingHeader }} />
)}
<NextIntlClientProvider messages={messages} timeZone="Europe/London">
<ReduxProvider>
<AppRouterCacheProvider>
Expand Down
2 changes: 1 addition & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default createMiddleware(routing);

export const config = {
// Skip all paths that should not be internationalized
matcher: ['/((?!api|_next|_vercel|.*\\..*).*)', '/_vercel/insights/view', '/en/:path*'],
matcher: ['/((?!api|_next|_vercel|.*\\..*).*)', '/_vercel/insights/view'],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"node": ">=20.0.0"
},
"scripts": {
"dev": "NODE_OPTIONS='newrelic' next dev --turbopack",
"dev": "next dev --turbopack",
"build": "next build",
"start": "NODE_OPTIONS='-r newrelic' next start",
"https:proxy": "local-ssl-proxy --source 3010 --target 3000 --cert localhost.pem --key localhost-key.pem",
Expand Down

0 comments on commit ef188b6

Please sign in to comment.