To control http / https related URL generators, some helpers must be overwritten.
Add param in .env:
1 |
USE_HTTPS=true |
Find helper file:
\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
if (! function_exists('asset')) { /** * Generate an asset path for the application. * * @param string $path * @param bool $secure * @return string */ function asset($path, $secure = null) { //logg(env('USE_HTTPS')); if(env('USE_HTTPS') == true){ $secure = true; } return app('url')->asset($path, $secure); } } if (! function_exists('url')) { /** * Generate a url for the application. * * @param string $path * @param mixed $parameters * @param bool $secure * @return \Illuminate\Contracts\Routing\UrlGenerator|string */ function url($path = null, $parameters = [], $secure = null) { if (is_null($path)) { return app(UrlGenerator::class); } if(env('USE_HTTPS') == true){ $secure = true; } return app(UrlGenerator::class)->to($path, $parameters, $secure); } } if (! function_exists('route')) { /** * Generate the URL to a named route. * * @param string $name * @param array $parameters * @param bool $absolute * @return string */ function route($name, $parameters = [], $absolute = true) { $url = app('url'); if(env('USE_HTTPS') == true){ $url->forceScheme('https'); } return $url->route($name, $parameters, $absolute); } } |