Redirecting of functions not working in Nuxt 3 app

Hi all, I hope someone can help with this - after checking the redirect guide and following an example Netlify web app I still cannot get redirects to work in my Nuxt 3 app - specifically redirects to serverless functions.

I have added a basic redirect from /api/* to /.Netlify/functions/:splat.

I suspect the Nuxt deployment includes a SPA redirect that is executed before my redirect.
The evidence for this is that the deploy log reports that three redirects were processed, and my netlify.toml file only has two:

3 redirect rules processed
All redirect rules deployed without errors.
[[redirects]]
  force = true
  from = "/api/*"
  to = "/.netlify/functions/:splat"
[[redirects]]
  from = "/*"
  status = 200
  to = "/index.html"

I have tried to download my deployed site but I only get a “Error during download” message.

I have tried to test the redirects when running functions locally and that does not work either. The functions runtime returns a “Cannot GET /api/entity” regardless of redirect rules in my Netlify.Toml file.

What should I look at next? I would like to find out where the Nuxt SPA redirect ends up post-deployment, and how I should mix in my specific redirect.

Did you try adding a status code to the redirect?

If yes, do you have a site name that we can check?

Hi @hrishikesh ,

Thanks for your response. Yes I have tried this with (and without) status=200.
I have also tried with (and without) force = true

My current assumption is that I should be able to run this locally, using netlify functions: serve, and be able to hit localhost:9999/api/{func}

This does not work, and neither does it work on the deployed version.

My site is: https://app.netlify.com/sites/stupefied-knuth-7b6748

Try adding the redirect to the _redirects file instead of netlify.toml. It appears that, Nuxt is creating its own redirect which take preference over your custom redirects. To me, that sounds like a bug that Nuxt should handle and take into consideration when generating redirects.