1

In Laravel 8 / livewire 2.5 / alpinejs 3 application in resources/js/app.js file I use https://github.com/harunurhan/idlejs to logout on some idle period of time.

But I want to set different period of time depending on APP_DEBUG in .env file.

I tried several ways described here : How to access the laravel .env variables inside javascript?

But none of them work for me.

How can I do it ?

Thanks in advance!

Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91
  • Seeing how you tagged this laravel then take a look at https://laravel.com/docs/8.x/mix#environment-variables . In short you can add another environment variable like `MIX_APP_DEBUG=${APP_DEBUG}` and use that one instead. Beware that all environment variables you expose to MIX will be visible in the browser so never reveal any server variables – apokryfos Oct 19 '21 at 07:39
  • "*none of them work for me*" - why not? Errors? There is no magic to using PHP vars in JS, and the question you linked to describes many valid options. Why don't they work? – Don't Panic Oct 19 '21 at 07:55

0 Answers0