Redirects effecting lambda functions

I have created some lambda functions which worked fine locally however when I have uploaded them my app is not working.

When going directly to my api call from the url I am being served my 404 page.
Is this due to my _redirect file which I created to allow for react router to work?

/* /index.html 200

If this is the case what should it be changed to?

i have tried this
/.netlify/functions/:function /.netlify/functions/:function 200

/* /index.html 200

the redirects playground says this is fine but the deploy says Invalid /.netlify path in redirect source
what is the issue?

Hi @AG-Labs can you let us know which site this is happening on so we can check? Thanks.

Fixed it now.
I did not have the netlify-labda build code in my package.json.
The tutorial I was following did not have this key part included :confused:

Glad you got that fixed!

Hi, @futuregerald I’m debugging a similar issue to what @AG-Labs explained. Site is deployed, but whenever I’m hitting a page that triggers a function I’m seeing a 404 in the network tab. Things are working okay locally, but still trying to eliminate causes. Site here

do you have netlify-lambda build /netlify-lambda in your build command on the netlify console?

That was the issue for me, I added a build:lambda script that ran this and appended it to the end of my normal build command.

Thanks for the help @AG-Labs, I did not have my build command added on the netlify console. :+1:

thanks for helping our @AG-Labs! :partying_face:

I’m having the same issue, but I do have the build command set up properly. At first I was getting a CORS error, then I added a headers section in my netlify.toml file, and that seems to have fixed the CORS error, but now I’m getting the 404 error due to what I’m assuming is the redirect rule that’s also in the .toml file.

  from = "/*"
  to = "/index.html"
  status = 200

  command = "yarn build && netlify-lambda build src/lambda"
  functions = "built-lambda"
  publish = "build"

  # Define which paths this specific [[headers]] block will cover.
  for = "/*"
    Access-Control-Allow-Origin = "*"

not sure if it is a copy/paste issue but does headers need to be at the same indent level as build?

I just fixed it and re-deployed, and still the same error, unfortunately.

Ahh, it turns out I’m a knucklehead and was trying to access the function at instead of I had assumed the path would be similar to what it was in my test environment.

1 Like

good catch - thanks for closing the loop!