Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plug module in controller only in production env?

How to plug module in controller only in production env?

Example:

plug BasicAuth, realm: "Admin Area", username: "admin", password: "pass"
like image 907
leon Avatar asked Dec 04 '25 23:12

leon


1 Answers

While @whatyouhide's answer is correct, be careful using Mix.env in your project outside of mix tasks. If you decide to use Exrm or relx to build OTP releases, the mix library will not be included and this will crash your app on startup.

As an alternative, you can add an :env key to each environment's respective config file with the env value in it and then use it much like you would Mix.env.

like image 84
Jason Harrelson Avatar answered Dec 07 '25 21:12

Jason Harrelson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!