Scalable grist instance with GRIST_ORG_IN_PATH

When we attempt to make Grist scalable, we hit some issue where the web client attempts to join the wrong domain for the doc workers.

As long as the subdomain is simple (domain.org and doc-worker-1.domain.org), it works fine.

However, when we attempt to make some boring subdomains like grist.subdomain.domain.org for the home server and doc-worker-1.grist.subdomain.domain.org for the worker, the client attempts to join doc-worker-1.domain.org), truncating parts of the hostname. Though I am not sure, but I suspect this is related to the extraction of the organization in the subdomains despite the GRIST_ORG_IN_PATH variable being set to some trutry value.

You can try it by tweaking a little bit the environment variables (especially I think the variable related to S3 storage) and then run docker-compose up -d.

NB: I had to patch a little bit getHostType so when the function would return native when the server is contacted with the internal doc URL (I would be happy to clean that and propose the fix in a PR):

Also it seems that instead using GRIST_SERVE_SAME_ORIGIN=true (doc worker url only have specific paths like /dw/doc-worker-...) circumvents the issue.

One thing I notice in code is that GRIST_ORG_IN_PATH must be set to exactly true to be considered true (other values – even if truthy – would be considered false).