0

We have build nuxt js multi tenancy web site. Now we want to fetch environment variable by domain for ex. We have 5 domain as below.

Note: We have used same source code for all domain.

  1. test1.com
  2. test2.com
  3. test3.com
  4. test4.com
  5. test5.com

So for this if i open test2.com then it should consider my test2.env or if i open test5.com then it should consider test5.com.

But the main problem is we have dynamic web side so any user will create his own website from our platform. So how can we create dynamic env file for web site and how to access that dynamically created env file

Nikhil Vaghela
  • 2,088
  • 2
  • 15
  • 30

1 Answers1

0

You should not try to reach a specific file but configure your environment to serve the proper variables. Either in a static way or dynamically.

Otherwise, if you really need to specify a new directory or filename, you can use this solution when launching your app.

yarn dev --dotenv variables/.env_file

kissu
  • 40,416
  • 14
  • 65
  • 133
  • This is not helpful becase in my case we need to create env file dynamically and access that created env file based on domain. – Nikhil Vaghela Aug 18 '21 at 11:05
  • Can you give more details on how you do create this `env` file exactly? Also, do you use Docker by any chance? – kissu Aug 18 '21 at 13:20
  • We have two different server one for vue(nuxt)js and other for backend(php) one's any user will register through our platform we will create domain for new registered user and call API to vue js server then will create env file as per user info. – Nikhil Vaghela Aug 23 '21 at 07:20