aaronlord / laroute

Generate Laravel route URLs from JavaScript.
MIT License
796 stars 138 forks source link

https url issue #72

Closed Chathula closed 6 years ago

Chathula commented 7 years ago

i want to get https URL when i call route method. but it always return http one.. i tried both absolute true and false. but didn't work.. my rootUrl is also have https...

Note: my site only works in https, http one always redirect to something not related to this project(i have added it, as i want. don't think about that :D )

current config...

var routes = {

            absolute: true,
            rootUrl: 'https://sub.example.com',

....
Chathula commented 6 years ago

this issue has been fixed!

changed AppServiceProvider file as below..

<?php

namespace App\Providers;

use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(UrlGenerator $url)
    {
        Schema::defaultStringLength(191);

        if(env('APP_ENV') != 'local')
        {
            $url->forceScheme('https');
            $this->app['request']->server->set('HTTPS','on');            
        }
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}