dusk: Exception: It is unsafe to run Dusk in production.
Exception: It is unsafe to run Dusk in production is fired when deploying in production.
https://github.com/laravel/dusk/blob/master/src/DuskServiceProvider.php#L43
Read discussion here https://laracasts.com/discuss/channels/forge/it-is-unsafe-to-run-dusk-in-production-error-when-trying-to-deploy
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 8
- Comments: 25 (8 by maintainers)
I just wanted to share what was my issue when getting this exception. When installing to production server I just needed to use the --no-dev flag.
FYI, you can also get this issue if you don’t have a .env file
@jarnheimer you should not have
DuskServiceProviderregistered in yourconfig/app.phpproviders. That’s what makes Dusk be registered in production and, hence, the exception, to protect you.Dusk exposes an endpoint that allows anybody to login as an user of your system by simply knowing the
idof the record.@bitclaw Just to clarify. An
envfile is just one way to setup environment variables for Laravel. By default, Laravel assumes production and after the environment variables are loaded, the value may be overwritten. If you don’t have a.envfile, but the operating system have actual environment variables, Laravel will pick that up. If you don’t have either, production will be assumed.I’m ashamed to admit that I’d forgotten the
--no-devflag on one of my newer projects.Either way, just wanted to add that if you arrive here and add the
--no-devflag as per @ajthinking’s comment, you may still face issues with your production server showing the error message.If that happens, try connecting to the server manually and completely rebuilding the vendor directory:
You are right I should have clarified if you don’t have the APP_ENV defined in either the .env file or as an environment variable since Laravel’s env() and config() helper functions use inside the PHP getenv() function