Closed
Description
Summary
I have a repo with NextJs and Netlify as well as next-intl installed. Up until the version 4.36.0, all worked fine, provided I set NEXT_DISABLE_NETLIFY_EDGE
to true
, but now when I upgrade it fails with an error middleware is not a function
and with the following stack trace
[next-dev] TypeError: middleware is not a function
at handler (file:///Users/davidecrestini/repo/sites/next-netlify-test/.netlify/edge-functions/next-dev/index.js:78:28)
at async FunctionChain.runFunction (https://64523ab4e7865600087fc3df--edge.netlify.app/bootstrap/function_chain.ts:390:22)
at async FunctionChain.run (https://64523ab4e7865600087fc3df--edge.netlify.app/bootstrap/function_chain.ts:310:20)
at async handleRequest (https://64523ab4e7865600087fc3df--edge.netlify.app/bootstrap/handler.ts:80:22)
at async Server.#respond (https://deno.land/std@0.170.0/http/server.ts:299:18)
I even installed @netlify/next
but that didn't solve the issue either, neither when I run the app locally (with netlify dev
), nor when I push and build it on Neltify.
Steps to reproduce
- clone https://github.com/KrustyC/next-netlify-test
- installed the dependencies and run
netlify dev
; everything should work - stop the app
- run
npm i @netlify/next @netlify/plugin-nextjs@latest next@latest
- run
netlify dev
- open http://localhost:8888 on your browser
A link to a reproduction repository
https://github.com/KrustyC/next-netlify-test
Next Runtime version
13.3.1 and above
Is your issue related to the app
directory (beta)?
- Yes, I am using the
app
directory
More information about your build
- I am building using the CLI
- I am building using file-based configuration (
netlify.toml
)
What OS are you using?
Mac OS
Your netlify.toml file
`netlify.toml`
[build]
command = "npm run build"
publish = ".next"
environment = { NODE_VERSION = "16.15.0" }
[dev]
command = "npm run dev"
[functions]
directory = "netlify/functions"
node_bundler = "esbuild"
external_node_modules = ["sharp"]
included_files = ["node_modules/sharp/**/*"]
[[plugins]]
package = "@netlify/plugin-nextjs"
[[plugins]]
package = "@netlify/plugin-lighthouse"
[plugins.inputs]
run_on_success = "true"
Your public/_redirects file
I do not have a public _redirects
Your next.config.js
file
`next.config.js`
const ms = require("ms");
const withNextIntl = require("next-intl/plugin")(
// This is the default (also the `src` folder is supported out of the box)
"./src/i18n.ts"
);
/** @type {import('next').NextConfig} */
const nextConfig = withNextIntl({
env: {
environment: process.env.ENVIRONMENT || "local",
baseUrl: process.env.BASE_URL || "http://localhost:8888",
},
experimental: {
appDir: true,
},
images: {
domains: [
"i.natgeofe.com",
"picsum.photos",
"images.ctfassets.net",
],
},
headers() {
return [
{
// Cache all content pages
source: "/((?!_next|.*\\..*).*)",
headers: [
{
key: "Cache-Control",
value: [
`s-maxage=` + ms("1d") / 1000,
`stale-while-revalidate=` + ms("1y") / 1000,
].join(", "),
},
],
// If you're deploying on a host that doesn't support the `vary` header (e.g. Vercel),
// make sure to disable caching for prefetch requests for Server Components.
// missing: [
// {
// type: "header",
// key: "Next-Router-Prefetch",
// },
// ],
},
];
},
});
module.exports = nextConfig;
Builds logs (or link to your logs)
https://app.netlify.com/sites/test-next13-netlify/deploys/645e0aaddcbd190008876f08
Function logs
Function logs (this are on my local)
[next-dev] TypeError: middleware is not a function
at handler (file:///Users/davidecrestini/repo/sites/next-netlify-test/.netlify/edge-functions/next-dev/index.js:78:28)
at async FunctionChain.runFunction (https://64523ab4e7865600087fc3df--edge.netlify.app/bootstrap/function_chain.ts:390:22)
at async FunctionChain.run (https://64523ab4e7865600087fc3df--edge.netlify.app/bootstrap/function_chain.ts:310:20)
at async handleRequest (https://64523ab4e7865600087fc3df--edge.netlify.app/bootstrap/handler.ts:80:22)
at async Server.#respond (https://deno.land/std@0.170.0/http/server.ts:299:18)
.next JSON files
I can not see any of the suggested files in my .next
folder