for our country detection, I am trying to see if I can extract the value of x-0-geo-country-code
to a variable, but I’m not having any luck
This works
.match({ path: '/', headers: {'x-0-geo-country-code': /US/i} }, ({redirect}) => { return redirect('/countries/us', { statusCode: 301 }) } )
But I was hoping to be able to do something more generic, like this:
.match({ path: '/', headers: {'x-0-geo-country-code': /:country/} }, ({redirect}) => { return redirect('/countries/:country', { statusCode: 301 }) } )
or even just refer to`x-0-geo-country-code directly in the redirect
i.e. something like this
.match({ path: '/', headers: {'x-0-geo-country-code': /^!(US|UM|VI|PR|AS|GU|MP)/i} }, ({redirect}) => { return redirect('/countries/${x-0-geo-country-code}', { statusCode: 301 }) } )
what I’m trying to achieve is…
If country is anything other than US/US territories, then redirect to /countries/