Closed alan-strickland-red closed 4 months ago
routeRules
must be serializable. As a function is not, you can't provide one through the config. Other options would be an own endpoint or using https://github.com/unjs/nitro/pull/2043 (experimental)
I see, just to expand my knowledge can you explain why must it be serializable?
The environment expansion change looks interesting, I will take a closer look at that.
Describe the feature
When using route rules for a proxy I would like to use environment variables to set the to property at runtime.
This would allow me to change the location of a proxy within a docker container.
Currently if you try to use environment variables to set the value of
routeRule.proxy.to
it uses the values from the environment on build.I think the following changes would be required.
https://github.com/unjs/nitro/blob/674089b309e7e73c78f25c5e9ca20f035059706d/src/runtime/route-rules.ts#L47
https://github.com/unjs/nitro/blob/674089b309e7e73c78f25c5e9ca20f035059706d/src/types/nitro.ts#L204
I haven't made use of 'redirect.to' yet but I suspect the same could apply.
Is there another way of accomplishing this, can you define route rules outside of the config file?
Usage
Additional information