You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by Supermog March 13, 2023
So I have a project that I added Sentry to, but the problem is that I have the nextConfig variable as an async function which the withSentryConfig doesn't accept. My next.config.js file looks like this:
const { withSentryConfig } = require('@sentry/nextjs');
const prismic = require('@prismicio/client');
const sm = require('./sm.json');
/** @type {import('next').NextConfig} */
const nextConfig = async () => {
const client = prismic.createClient(sm.apiEndpoint);
const repository = await client.getRepository();
const locales = repository.languages.map(lang => lang.id);
return {
reactStrictMode: true,
swcMinify: true,
compiler: {
styledComponents: true,
},
i18n: {
// These are all the locales you want to support in
// your application
locales: locales,
// This is the default locale you want to be used when visiting
// a non-locale prefixed path e.g. `/hello`
defaultLocale: locales[0],
localeDetection: false,
},
};
};
module.exports = withSentryConfig(
nextConfig,
{ silent: true },
{ hideSourcemaps: true },
);
I've also played around with it and using await on the nextConfig argument or calling the function also does not work. I've tried converting it to .then blocks but that also does not work.
Without Sentry it works well because nextjs accepts nextConfig as an async function but Sentry does not. Is there a workaround to this?
error - Error: Invalid locale returned from getStaticPaths for /[uid], the locale en-gb is not specified in next.config.js
at /home/supermog/Repos/marketing-cms/node_modules/next/dist/build/utils.js:667:23
at Array.forEach (<anonymous>)
at Object.buildStaticPaths (/home/supermog/Repos/marketing-cms/node_modules/next/dist/build/utils.js:621:17)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
type: 'Error',
page: '/[uid]'
}
This is the error message. It occurs whenever I go to a URL that the 404.tsx component should handle.
Modified one template to use the async function instead, as adding an
additional variant to an already bloated integration test runner felt
meh.
Note that type from
#7444 is incorrect.
It should be:
```js
const nextConfig = async () => {
/** @type {import('next').NextConfig} */
return {};
}
```
and not:
```js
/** @type {import('next').NextConfig} */
const nextConfig = async () => {
return {};
}
```
Note #2: async function handling works for `next >= 12.1` only:
https://nextjs.org/docs/app/api-reference/next-config-js/pageExtensions
Verified the behavior locally using provided sample config from the
original issue.
Fixes#7444
Discussed in #7433
Originally posted by Supermog March 13, 2023
So I have a project that I added Sentry to, but the problem is that I have the nextConfig variable as an async function which the
withSentryConfig
doesn't accept. My next.config.js file looks like this:I've also played around with it and using await on the nextConfig argument or calling the function also does not work. I've tried converting it to .then blocks but that also does not work.
Without Sentry it works well because nextjs accepts nextConfig as an async function but Sentry does not. Is there a workaround to this?
"@sentry/nextjs": "^7.42.0",
"next": "13.1.2",
"react": "18.2.0",
The text was updated successfully, but these errors were encountered: