Home
Support Forums

Can't add a redirect for .netlify/functions

Possibly a dumb mistake on my part, but I just created a new Netlify function and wanted to make an alias. I did this:

/.netlify/functions/getPageViews /api/getPageViews

This creates an error:

Could not parse redirect number 120:
  {"from":"/.netlify/functions/getPageViews","query":{},"to":"/api/getPageViews","conditions":{}}
"path" field must not start with "/.netlify"

I can’t make an alias for serverless functions?

Hi @cfjedimaster

If you want to create an alias/rewrite you need to do

/api/getPageViews    /.netlify/functions/getPagesViews

So the other way round to what you have.

Sigh - duh and thank you. The sad thing is that this was in a file of like 100 other examples.

The version for that would be something like:

/api/* /.netlify/functions/:splat 200!.