build icon indicating copy to clipboard operation
build copied to clipboard

Don't create context-specific redirects in netlify.toml

Open fool opened this issue 3 years ago • 0 comments

Recently a customer shared their netlify.toml with us and we discovered hundreds of redirects like this, which attempt to leverage a [[context]]:

[[context.release.redirects]]
    from = "/assets/dist/json/animations/stats-rotator-small.json"
    to = "/assets/dist/json/animations/stats-rotator-small.json"
    status = 200

However, per an internal discussion in netlify slack, this does not actually seem to be a supported feature of our redirects. Netlify's docs say the same thing:

Certain keys, such as [build] and [[plugins]] but not [[redirects]] or [[headers]], allow you to set [context] properties based on the kind of deploy. These keys are context-aware.

fool avatar Jan 18 '22 16:01 fool

Hey can someone clarify the behaviour for me that we should create for the user?

  • Is it just omitting the "faulty" redirects and then logging an error message?
  • should we error the build?
  • or should we try to implement the feature for context aware redirects?

cc @kitop, @fool

lukasholzer avatar Aug 17 '22 07:08 lukasholzer

Lets go with option one:

Omitting the "faulty" redirects and then logging an error message?

The context-specific redirects are being ignored currently so this won't change the behavior for the user, and they will get at least a warning.

kitop avatar Aug 17 '22 08:08 kitop

There shouldn't be a user warning. This isn't something they control. We should just ensure that they can't be created.

ascorbic avatar Aug 17 '22 12:08 ascorbic