Lambda function deployed but not found

I succeeded in deploying a lambda function at https://my_host/.netlify/functions/my_function, as the “Functions” tab of my Netlify control panel states. However when accessing the URL that tab mentions I just get “{“message”:“Route GET:/.netlify/functions/my_function not found”,“error”:“Not Found”,“statusCode”:404}”.

The function logs doesn’t help here, as just add some access line, like “12:22:43 PM: 6d920b2e Duration: 2.36 ms Memory Usage: 114 MB”

Note: this works locally using netlify dev

If this line is logged, it means your function was successfully called. Not sure why it would return a 404 unless that’s the status you’re returning from the function.

That’s a fair hypothesis that 404 would be returned by the function itself, although that’s not what I can see using netlify dev with the same URL parameters.

In order to understand how that could happen, I would need the logs of the delta function itself. Is the reason why they are not available because it is hosted by AWS?

Have you logged something using the function?

If you could share the site URL that you’re talking about, we can check this further.

Indeed I can see the function’s logs when I add some :+1:

It looks that the function returns 404 because it receives GET:/.netlify/functions/my_function instead of GET:/my_function. Again, this works locally using netlify dev however.

Hi @javarome,

Would you please share some identifier of the website that can help us check this?

Yes but how can I share this privately?

You should be able to share it via a private message.

Are you trying to call the function from within the function?

No I don’t. The function is an aws-lambda-fastify wrapping of a fastify instance, which registers a single plugin/context, which itself registers several routes.

As a workaround, I made it work by adding .netlify/functions as a prefix of my route :man_shrugging:

Well, that’s great that you’ve a workaround, but I’m still confused as to why the function is calling itself as saying route not found.

What my question basically is that, what exactly is triggering the function to log Route not found and the address being the same as that of the function.

The function doesn’t call itself. It calls a fastify instance with the request, then fastify tries to recognize the request as a registered route. When fastify routes were declared as “my_function”, it returned a 404 when receiving “.netlify/functions/my_function”. So I declared the fastify routes with a “/netlify/functions” prefix.

Well, glad you found the workaround yourself then. I have never used Fastify, so I could not have figured this myself.