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!

2
  • Seeing how you tagged this laravel then take a look at 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 Commented Oct 19, 2021 at 7: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? Commented Oct 19, 2021 at 7:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.