Detect host automatically

May be useful to replace domain.js by automating the detection.