Reputation: 725
I have two environments, development and production.
In master.blade layout file, I point to my local js file like that:
<script src="http://192.168.2.40/js/jscript.js" type="text/javascript"></script>
However, I convert this line to the following one for production server.
<script src="http://s.mysite/js/jscript.js" type="text/javascript"></script>
It is very annoyting and error-prone to switch between them. How can I solve this problem in an environment independent way.
Upvotes: 0
Views: 132
Reputation: 50787
Don't hardcode your addresses.
In your .env
file add a new record:
//.. env stuff
APP_URL=http://192.168.2.40 //or http://s.mysite on your production server
Then in your config/app.php
if you don't already have it, add a declaration for your url
:
'url' => env('APP_URL', 'http://localhost'),
Upvotes: 2