Edge functions with a Gatsby site

How do I set redirects appropriately so that my edge functions work on a Gatsby site?

All the usual Netlify functions work well at /.netlify/functions/ but the edge functions don’t.

I put the following line in my netlify.toml

function = “clientLocation”
path = “/client-location”

and it works in dev using the netlify cli, but once built in production /client-location shows the Gatsby 404 page.

Hi @restieauxbro,

Which site is this about?

Hiya! It’s https://tp-ai-assistant.netlify.app

Hey there,

Thanks for your patience! I don’t see a 404 when I load your site-- are you still encountering obstacles? If you are, can you please share the edge function you are using?

It’s saying an unhandled error in the function is causing it to crash.

The deployment failed while serving the request.

The code is

export default (request, context) => {
  const geo = context.geo;
  return context.json(geo);

It works fine in development

Hey @restieauxbro,

There seems to be something weird happening here. We’ve escalated this to the developers and would follow up once we have more information.

1 Like

Hi @restieauxbro! @ewanvalentine and me looked into this, and it seems like the __default is not defined problem stems from a bundling error around some code that calls some Supabase endpoints. Could you share a small reproduction repository with us? That’d make it easier for us to get to the ground of it.

Looked into it some more, and it looks like the edge function causing the error is not the one you mentioned above, but one called programme-search. Could you check if that also works in local development?

1 Like

That was it! Thank you, all fixed now <3

1 Like