Hey all. Just successfully deployed my app but struggling to fix one nagging issue. Is it possible to dynamically update a variable inside a redirect? The redirect URL will stay the same, it’s just the “searchTerm” variable that’ll be set when you search for something. If I hardcode searchTerm to milk for example then it works. I need to redirect it as I’m getting blocked by cors. Locally I’ve been using cors-anywhere to get around this issue. The other 2 stores are already working if someone visits the app, it’s just ‘Countdown aka Woolworths’ that I’m trying to sort.
// netlify.toml
[[redirects]]
from = "VITE_PROXY"
to = "https://www.woolworths.co.nz/api/v1/products?target=search&inStockProductsOnly=true&search=${searchTerm}"
status = 200
force = true
I had a look at https://docs.netlify.com/configure-builds/file-based-configuration/#inject-environment-variable-values but unfortunately that only mentioned environment variables & not dynamic ones. Also had a go at searching the forums. Lastly I tried referencing “VITE_PROXY” + my variable when fetching, but that just concatenates it & nullifies the redirects rule. Hoping someone could help, thanks!