Redirects to function endpoints not working using netlify cli "netlify dev"

I’ve got a project where I had some redirect rules set up to handle some “functions” endpoints. It worked well for a while but when I updated the CLI version recently it seems to have stopped.

I can hit a function path directly, as in http://localhost:8888/.netlify/functions/dboxDecks/dboxDecks.js and it will work fine.

However when I try to go to its redirect ‘from’ path http://localhost:8888/decks it simply serves the root, index file of the project .

I should point out that when I used to run netlify dev a secondary terminal window launched and displayed some port information. Now this does not happen.

Here’s my netlify.toml file:

[build]
  publish = "build"
  functions = "functions"

[[redirects]]
  from = "/generate"
  to = "/.netlify/functions/generateSignature/generateSignature.js"
  status = 200

[[redirects]]
  from = "/decks"
  to = "/.netlify/functions/dboxDecks/dboxDecks.js"
  status = 200

[[redirects]]
  from = "/slides"
  to = "/.netlify/functions/dboxSlides/dboxSlides.js"
  status = 200

[[redirects]]
  from = "/thumbnail"
  to = "/.netlify/functions/dboxDeckThumbnail/dboxDeckThumbnail.js"
  status = 200

Anyone know what’s going on?

Hey there,

Can you give this topic a read, please, and let me know if this helps?

So I uninstalled netlify cli and reinstalled with npm i -g netlify-cli@latest and the issue still persists.

@willkp Can you please post the results of netlify version --verbose!

I have the same problem.

When I run $ netlify dev or $ netlify dev --live the redirects rules does not works.

If I publish the project all run correctly.

My Netlify config file is like that:

[build]
    command = "npm run build"
    publish = "dist"
    functions = "functions"
[dev]
    framework = "#custom"
    command = "npm run dev"
    targetPort = 3030

My _redirects file is that:

/api	/.netlify/functions/api		200

This is not only a issue with functions redirects. It’s not working with any redirect rule.

Here the link to the demo project in production:

https://nervous-allen-34edcb.netlify.app/

Here the link to the code:

And a capture with my netlify version --verbose!

As far as I know, we cannot host functions with the string “api” in their name - obscure bug. Mind trying it with a differently named function just to be sure?

Hi fool,

Using the string “api” in the name of my functions works well on Dev and Production. I can’t find any obscure bug.

However, I have changed the name of the function and the redirection and the problem persists.

Where there is a bug is in the latest version of Netlify CLI.

I found this and It’s not only a Gatsby problem:

Thanks

Hey there,

Thanks for closing the loop and linking the bug.

As per https://github.com/netlify/cli/issues/890, netlify-cli@2.51.0 has just been released which contains a fix for this issue.

Everything is fine width the update.

Thanks.