Netlify edge functions detected but not deployed

I am currently working on a 2-year-old NextJS application with the aim of implementing Contentful previews through the use of NextJS API Routes. The functions have been developed and they work fine locally. I am, however, having a tough time deploying them to Netlify.

The build overview shows “Deployed Functions and Edge Functions” ( screenshot 1), however, the Build Summary shows “No Edge Functions Deployed” ( screenshot 2). The build logs also contain the function bundling process. ( screenshot 3 ).

The custom functions directory has been specified in the netlify.toml file as shown below;

  command = "yarn build && yarn conditionally-build-storybook && yarn sitemap"
  publish = "out"
  environment = { NODE_VERSION = "14", YARN_VERSION = "1.19.0" }
  edge_functions = "/src/pages/api"
  functions = "/src/pages/api"

Additional version details;

  • “next”: “12”
  • “react”: “^16.8”

I have tried the following to fix this issue, all to no avail.

  1. Upgrading the Next.js version from 10 to 12.
  2. Refactoring the functions into a /pages/api directory against the custom src/pages/api directory.
  3. Change the node engine from 12 to 14

I really will appreciate a hint at what’s missing here.

Cc: @perry @audrey

Did you declare the Edge Functions as explained here:

The declarations worked, and the edge functions have been detected and deployed.

A little more probe though, I created a new Next.js 13 project, and the edge functions where automatically detected without having to declare them.

Why weren’t they automatically detected for this project?

Following these declarations, I think Netlify now expects the serverless functions to run as Netlify Functions ( using the Netlify function’s syntax et al).

What I want is to have the Next.js API Routes deployed and accessible. Without the declaration, I am getting a 404 error when I try to access the function endpoint.

Which ones? The ones created by you or one created by Next.js Runtime? If it’s the latter, it worked because the Runtime declared it for you during the build. If it’s the former, it sounds unlikely that it would work without declaration.

It was the boilerplate API route that was generated alongside the Next.js project.

@hrishikesh any insight on this?

Do i need to make a clarification on the issue?

Hi @hrishikesh,

Bumping this as there’s not been a response from you.

It’s still not clear what that means. What boilerplate API? Next.js API routes don’t run on Edge Functions at the moment.

What was amiss for anyone experiencing this issue was the netlify/next-runtime.

Unlike Netlify claims, this runtime is not automatically used within the build pipeline for much older projects (mine was a 3-year-old application). However, it is automatically used for new Next.js projects bootstrapped through the Netlify console. ( From my various testings )

You need to follow the manual installation process to install the runtime in order to have the Next.js API routes deployed.

Cc: @hrishikesh

Hi @vickywane :wave:t6: ,

thank you for coming back and letting us know what you used to resolve this problem and providing documentation. This will help others on this in the future.

1 Like