Netlify.toml folder with nuxtjs and netlify-cli

I have a nuxtjs website with a netlify.toml file that contains build instructions and conditional redirects. I can’t figure out how to have both sections working correctly when running ntl dev.

What I tried:

  • Place the file in the static folder. The redirects work correctly but the build instructions are ignored.

  • Place the file in the root folder. The redirects are ignored.

  • Two netlify.toml files, the one with build instructions in the root folder and the one with the redirects instructions in the static folder, however the latter is ignored.

Any solution to suggest? Thanks a lot!

Hi, @giovanni, there is currently no support for conditional redirect rules in the netlify.toml file. I also don’t think we support multiple netlify.toml files unless it’s in the context of a monorepo.

What I would recommend is moving your redirects to a _redirects file instead. You can then conditionally copy that _redirects file to your ‘publish directory’ based on context.

Thank you @Dennis

Conditional redirects is probably the wrong name, but I mean something like this:

[[redirects]]
  from = '/'
  to = '/es/'
  status = 301
  force = true
  [redirects.headers]
    Language = ['es']

[[redirects]]
  from = '/'
  to = '/br/'
  status = 301
  force = true
  [redirects.headers]
    Language = ['br']

That syntax works in a netlify.toml file, but I guess that can’t fit in a _redirects file, isn’t it?

However, after some more tests, I realize that if I place everything in the same file in the root folder, everything works as expected when deployed. The redirect not working on ntl dev is the best compromise right now.

1 Like

thank you for sharing!