I’m defining some variables for each environment in my .toml file like this
[env.test]
name = "proxy-worker-test"
routes = ["proxy-test.letsbit.com/*"]
vars = { REDIRECT_WP_URL = "https://landing.letsbit.io/", REDIRECT_DEFAULT_URL = "https://test.letsbit.io/" }
[env.prod]
name = "proxy-worker-prod"
routes = ["proxy-prod.letsbit.com/*"]
vars = { REDIRECT_WP_URL = "https://landing.letsbit.io/", REDIRECT_DEFAULT_URL = "https://letsbit.io/" }
But when I try to publish it via wrangler publish --env test
I get the following
This is how I try to access the variable like the documentation says
const router = (pathname: string) => {
const routerObjectLiteral: { [key: string]: UrlRedirect } = {
[PATHNAME_HAMPTON_HILTON]: REDIRECT_WP_URL,
};
const redirect = routerObjectLiteral[pathname];
if(redirect) {
return `${redirect}${pathname}`
} else {
return `${REDIRECT_DEFAULT_URL}${pathname}`
}
};