简体   繁体   中英

How to create multiple env file in vue / nuxt js and access env by domain

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM