opened 08:22AM - 13 Oct 23 UTC
type: bug
Ecosystem: Frameworks
### Summary
Website is working normally, but when setting NextJS in preview m…ode to see live Sanity data, Netlify gives a 500 error. Locally, the preview mode works. Also, in a Docker image it works as expected. Netlify is the only place where preview mode fails.
### A link to a reproduction repository
Private repository
### Expected Result
No error, just NextJS on Netlify in preview mode getting live data from Sanity.
### Actual Result
A 500 error in the browser and the error log below.
### Steps to reproduce
Don't know.
### Next Runtime version
4.40.3-rc.0
### Is your issue related to the `app` directory?
- [ ] Yes, I am using the `app` directory
### More information about your build
- [ ] I am building using the CLI
- [X] I am building using file-based configuration (`netlify.toml`)
### What OS are you using?
None
### Your netlify.toml file
<details>
<summary>`netlify.toml`</summary>
```toml
[[plugins]]
package = "@netlify/plugin-nextjs"
[[plugins]]
package = "@netlify/plugin-sitemap"
[plugins.inputs]
exclude = [
'.next/404.html',
'.next/404/index.html',
'.next/500.html',
'.next/500/index.html',
]
```
</details>
### Your public/_redirects file
None
### Your `next.config.js` file
<details>
<summary>`next.config.js`</summary>
```js
/** @type {import('next').NextConfig} */
module.exports = {
i18n: {
defaultLocale: 'nl',
locales: ['nl'],
},
images: {
domains: ['cdn.sanity.io'],
},
output: 'standalone',
swcMinify: false,
async redirects() {
const sanityRedirects = await fetchSanityRedirects();
return sanityRedirects;
},
};
```
</details>
### Builds logs (or link to your logs)
None
### Function logs
<details>
<summary>Function logs</summary>
```js
Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/amp-context'
Require stack:
- /var/task/node_modules/next/dist/shared/lib/head.js
- /var/task/node_modules/next/head.js
- /var/task/.next/server/pages/index.js
- /var/task/node_modules/next/dist/server/require.js
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js
- /var/task/___netlify-handler.js
- /var/runtime/index.mjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at /var/task/node_modules/next/dist/server/require-hook.js:54:36
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at mod.require (/var/task/node_modules/next/dist/server/require-hook.js:62:32)
at require (node:internal/modules/cjs/helpers:121:18)
at Object.<anonymous> (/var/task/node_modules/next/dist/shared/lib/head.js:29:34)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/var/task/node_modules/next/dist/shared/lib/head.js',
'/var/task/node_modules/next/head.js',
'/var/task/.next/server/pages/index.js',
'/var/task/node_modules/next/dist/server/require.js',
'/var/task/node_modules/next/dist/server/next-server.js',
'/var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js',
'/var/task/___netlify-handler.js',
'/var/runtime/index.mjs'
]
}
```
</details>
### .next JSON files
None