[[redirects]] rules not working as expected on netlify.toml file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[[redirects]] rules not working as expected on netlify.toml file

I have some serverless functions setup in netlify. The default API endpoint look like: ๐Ÿ‘‰ /.netlify/functions/fun I want to customize these URLs to something like: ๐Ÿ‘‰ /api/fun But I'm getting error "cannot find module ...../api" This is my netlify.toml file. [build] ย  functions = "lambda" [[redirects]] ย  from = "/api/fun" ย  to = "/.netlify/functions/fun" ย  status = 200 ย  force = true What is the problem here. Help if you have any any experience with this.

1st Mar 2021, 2:52 AM
Bibek Oli
Bibek Oli - avatar
1 Answer
0
Never used netlify so I'm not actually sure but try swapping values of 'from' and 'to' fields. ... [[redirects]] from = "/.netlify/functions/fun" to = "/api/fun" ...
1st Mar 2021, 3:14 AM
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰ - avatar