Netlify redirects

Hey there,

I’ll start by saying I have read the support guide for making re-directs work - very informative thank you. I have also read a bunch of other posts about this. However, redirects are still not working. At this point I’m not sure if it is syntax (although it looks right) or if there is some kind of TTL or DNS issue on adding these.

I can see that my redirects are being processed in the build and they are in a netlify.toml file. Here is the very first of the test redirects: (Note the file does start with a comment line - so not sure of that is an issue)

# Example redirect
# https://docs.netlify.com/routing/redirects/
[[redirects]]
    from = "/test-redirect"
    to = "/visit/eat-and-drink"
    status = 301
    force = false

The url does not exist and so I should not have to force. But it does not re-direct. The full Netlify domain is: https://bright-rabanadas-7cab2c.netlify.app/test-redirect

Any help would be appreciated.

Cheers

@mattbondi The order of redirects matters, and it looks like you might have one that is catching all routes and proxying to the /index.html?

For example, you’d expect this to be a 404, (https://bright-rabanadas-7cab2c.netlify.app/this-clearly-does-not-exist), but it’s returning a 200 and the same content as your /test-redirect page.

If that’s the case then see the Rule processing order section:

https://docs.netlify.com/routing/redirects/#rule-processing-order

Hey @nathanmartin - thanks for this. That is the very first redirect… but I did some digging and see that a plain _redirects file is included in the build and it contains:

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

The problem now is that - we have not added that file in our code… reading the above implies it is set at functions - but we do not have any functions either. Looks like a default thing from Netlify.

So how would I get around this?

Cheers

@mattbondi I can’t advise how to get around it, as I don’t work with Nuxt, but I’d guess it’s related to Nuxt having SSR.

So those rules may be correct.

You hadn’t mentioned Nuxt or SSR prior, so I’d answered presuming that you were working with only static files and Netlify redirects.

Thanks @nathanmartin - yes I had not mentioned that set up as I was dealing directly with redirects in a Netlify sense… Nuxt and SSR functions in theory should not have affected what may have been an issue in my netlify.toml file.

However, the architecture obviously is affecting this and so I will hunt in that area. Thanks again for your help.

1 Like

For anyone else who ends up here… it turns out that if you are using Nuxt 3 it will automatically generate a _redirects file in its config. This then overrides your netlify.toml unfortunately.

The solution I am using is to download the deployment from Netlify, get the _redirects file that is generates and add your redirects above the ones that Nuxt creates - and of course save it in your public directory. Then all seems to work. It just means that I don’t see a way to use a toml file for redirects sadly.

@mattbondi That sounds legitimately awful.