Redirects not working for local function execution

I’m trying to get redirects to work with a local function. I have a simple redirect rule in my netlify.toml file:

  from = "/api/v1/:splat"
  to = "/.netlify/functions/main/"
  status = 200
  force = true

And a main function that was generated by the netlify functions:create command:

const handler = async (event) => {
  try {
    const subject = || 'World'
    return {
      statusCode: 200,
      body: JSON.stringify({ message: `Hello ${subject}` }),
  } catch (error) {
    return { statusCode: 500, body: error.toString() }

module.exports = { handler }

When I run deploy the function, life is good!

curl -sL | jq
  "message": "Hello World"

But locally, I’m having trouble. Hitting the function ignoring the redirect is fine. I start the server with netlify functions:serve --debug --port 8080:

curl -sL http://localhost:8080/.netlify/functions/main/test | jq
  "message": "Hello World"

But trying the redirect doesn’t work:

curl -sL http://localhost:8080/api/v1/test     
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<pre>Cannot GET /api/v1/test</pre>

Any tips? I do recall that the redirects should work locally but maybe I’m daydreaming. Repo is here:


functions:serve doesn’t use your redirects. Simply run netlify dev.

Amazing! thanks, this works perfectly