I've read How to configure user specific hosts file on Windows, it has no answers and is from 2012 so the chance that anyone revives it is pretty much zero.
Here's my use case: we have a nodejs tool suite that lets users generate content that is saved to their own subdomain on the production system. Say it's deployed on example.org
, and you're registered with username xyz
then the content you generate ends up on xyz.examplecontent.org
(different domain because of obvious security issues).
The problem is that this also needs to be tested locally by devs, including the system that does username-prefixed domain routing. Since on a clean checkout, there are no prebaked users, each dev would have to set up some users (this part is essential, because it tests the user-creation process), but then also manually edit their hosts
file so that there are (As far as the computer knows) user subdomain hosts that will resolve correctly.
It's possible to sort-of-kind-of automate the hosts modifications using libraries like https://npmjs.org/package/hostile or https://npmjs.org/package/mod-hosts (discounting https://npmjs.org/package/local-tld because it's OSX only) but since modifying the hosts file on windows or OSX requires administrative rights, and you're definitely not going to run any app with admin rights, these libraries are cool, but not actually usable.
Are there any Node.js packages that I can't find when searching http://npmjs.org for "hosts" that would solve this issue, or do windows and OSX have ways to set up complimentary hosts files so that additional hosts rules can be specified without polluting the master file, and not needing admin rights?
note: Answers of the kind "this automation tool can do that for you and runs on *n*x, OSX and windows, but requires ruby/python/perl/whatever" are also perfectly acceptable of course. As long as it's cross-platform and doesn't require admin rights, that's already better than hand curating.