This plugin replaces the placeholders defined in _redirects
file dynamically on preBuild stage.
Imagine you have a file for your redirects defined in _redirects
file:
/api/checkout/* {{env:TEST_API_URL}}/:splat 200
/api/auth/* {{env:ENV_NON_EXISTENT|http://default-domain.com}}/api/auth/:splat 200
And you defined TEST_API_URL
environment variable to be https://this.is.test/hey
With this plugin, your published _redirects
will be transformed to:
/api/checkout/* https://this.is.test/hey/:splat 200
/api/auth/* http://default-domain.com/api/auth/:splat 200
{{env:ENV_VAR_NAME}}
or {{env:ENV_VAR_NAME|default_value}}
(if the variable does not exist, default_value will be written)
[[plugins]]
package = "netlify-plugin-redirect-env-placeholders"
[plugins.inputs]
source = '_redirects'
base = '/opt/build/repo/'
Both inputs are optional:
name | description | default |
---|---|---|
source |
Source filename (It should be on the root path of your project) | _redirects |
base |
Base path of the build during preBuild step where files exist | . |
If you would like to use this plugin with netlify-plugin-contextual-env, please make sure that this plugin is added afterwards.