Netlify.toml Redirects Not Applied Nuxt3

on my site, I have setup a netlify.toml file in the root of my nuxt 3 project and have included the following contents:

[[redirects]]
    from = "/proxy/*"
    to = "https://api.mysite.com/:splat"
    status = 200
    force = true

In the build log, it does state that three redirects are processed, however when I view the build files, I only see the two default netlify redirects:

/__nuxt_error	/.netlify/functions/server 200
/* /.netlify/functions/server 200

I’m not sure what I’m doing wrong or why this redirect is not being placed into the build. I did view the debugging guide here: [Support Guide] Making redirects work for you - troubleshooting and debugging
However, it didn’t really apply since the netlify dashboard shows three rules processed, even though only two are being placed in the redirects file.
image

EDIT
I have now manually included a _redirects file in my /public dir to ensure that it gets generated:

/__nuxt_error	/.netlify/functions/server 200
/* /.netlify/functions/server 200
/proxy/*  https://api.mysite.com/:splat  200!

But the proxy still does not function.
For example, navigating to my api: https://api.mysite.com/news returns a list of news
However: https://main--mysite.netlify.app/proxy/news just returns a 405 error.

Update:

I was unable to get this working using netlify’s redirects, but for anyone needing to accomplish something similar, I solved it by configuring nitro in the following way in my nuxt.config.js:

	nitro: {
                ...
		routeRules: {
			'/proxy/**': { proxy: process.env.NUXT_PUBLIC_API_URL + '/**' },
		}
	},

thanks for writing back and sharing your solution and code. (:

1 Like