GF_SERVER_ROOT_URL environment variable not working

I am running my grafana on fargate and I have connected the grafana instance with Postgres. I am passing my configurations using the environment variables and from the logs I can see that they are overriding the configurations. But GF_SERVER_ROOT_URL and GF_SERVER_DOMAIN remain the same. And when I try to use Generic Oauth I get redirect uri mismatch.