Netlify Functions — can you change the path to the function?

I’m using Netlify Functions to serve users with JavaScript disabled a no-js version of my site.

You can see it here: Dice Roller

Users submit a form with the number of dice they’d like to roll — if they have JavaScript enabled, the form doesn’t submit and instead dice are rolled on the same page. However, if JavaScript is disabled, the form submits, and sends a request to /.netlify/functions/roll-dice

This works great — but the average user may not know what netlify is, or maybe even what a function is — and i’d like to avoid any confusion and change it so it says something more appropriate. Like /no-js/roll-dice

Is this possible? If so, how could it be achieved?

Yes you can easily setup redirects in your netlify.toml file. See the reference here:

https://docs.netlify.com/routing/redirects/

See also this blog article:

https://www.netlify.com/blog/2021/12/13/setting-up-redirects-on-netlify/

2 Likes

Amazing, thank you, that solved it.