Setting a different functions folder name in netlify.toml or online via admin does not get reflected in final function URL. So if one sets netlify.toml -> build -> functions = "./api" the URL for the function via the web is still /.netlify/functions/hello.js.
How does one fix this so that the URL matches the functions folder name?
Hi @markshark, it seems you cannot change the production URL of your function.
The setting in the netlify.toml only corresponds to the path of your functions folder in your code.
@DavidWells thank you for this solution, looks great. Just one concern. How do redirects on Netlify affect performance? Does one take a small hit when using them? One of the best features of functions is perf and scaleability over the same feature run serverside via a framework such as Laravel or Rails.
Also, I get this error on Netlify Dev:
ā Warnings while parsing netlify.toml file:
1: {"from":"/.netlify/functions/*","to":"/api/:splat","status":200} -- Invalid /.netlify path in redirect source
I think the from and to swapped in your example? This works as expected:
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
status = 200
I have also tried this with versions of netlify-cli back to 2.22, and the result is the same. Which version of netlify-cli are you using that works with the [[redirects]] block you provided?
hey there, thanks for letting us know. The CLI team tells me they have just released a new version that should fix this, can you upgrade and let me know whether the issue is still occurring?
Thanks, @perry! I installed netlify-cli/2.49.0 with npm i -D netlify-cli@latest and Iām happy to report that the CLI is working beautifully, with no error messages caused by the [[redirects]] block in netlify.toml.