Skip to content

Accessing top domain page #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
asivaneswaran opened this issue Jun 7, 2020 · 8 comments
Closed

Accessing top domain page #39

asivaneswaran opened this issue Jun 7, 2020 · 8 comments

Comments

@asivaneswaran
Copy link

Hi,

So when I try to access my top domain home page: main.test , I get this:

Target class [currentTenant] does not exist.```

But I would like to be able to access this page so I can have a home page.
@anwarx4u
Copy link

anwarx4u commented Jun 7, 2020

@asivaneswaran , I think, you may manage Top/Based domain by using Laravel domain route. An example is following:

Route::domain('yourtopdomain.com')->group(function () {
    Route::get('/', function () {
        return redirect('home');
    });

    // Others route goes there.

    
    // Catch All Route
    Route::any('{any}', function () {
        abort(404);
    })->where('any', '.*');

});

@asivaneswaran
Copy link
Author

asivaneswaran commented Jun 8, 2020

@anwardote

Route::domain(env('APP_URL'))->group(function () {
    Route::get('/', function () {
        return redirect('home');
    });

    // Others route goes there.


    // Catch All Route
    Route::any('{any}', function () {
        abort(404);
    })->where('any', '.*');

});

Route::middleware('tenant')->group(function() {
    // Tenant routes
});

But I still get the error.

@anwarx4u
Copy link

anwarx4u commented Jun 8, 2020

@asivaneswaran

I think, something wrong at env('APP_URL'). Actually env('APP_URL') contains APP URL. But the domain route accepts the only domain name.

Example - If your APP URL is http://www.abc.com then its domain name is abc.com

@asivaneswaran
Copy link
Author

@anwardote I changed it to the right domain, but it doesn't work.

Route::domain('uleague.test')->group(function () {
    Route::get('/', function () {
        return "TEST";
    });

    // Others route goes there.


    // Catch All Route
    Route::any('{any}', function () {
        abort(404);
    })->where('any', '.*');

});

Route::middleware('tenant')->group(function() {
    Route::get('login/discord', 'Auth\DiscordController@redirectToProvider');
    Route::get('login/discord/callback', 'Auth\DiscordController@handleProviderCallback');

    Route::post('riot/match-results', 'RiotController@matchResults')->name('riot.match-results');

    Route::resource('series', 'SeriesController')->only(['index', 'show']);
    Route::resource('teams', 'TeamController')->only(['index', 'show']);
    Route::resource('players', 'PlayerController')->only(['index', 'show']);

    Route::get('pages/{page}', 'HomeController@page')->name('pages.show');

    Route::get('standings', 'HomeController@standings')->name('standings');
    Route::get('/', 'HomeController@home')->name('home');
});

@anwarx4u
Copy link

anwarx4u commented Jun 8, 2020

what is the error?

@asivaneswaran
Copy link
Author

Illuminate\Contracts\Container\BindingResolutionException
Target class [currentTenant] does not exist.

@anwarx4u
Copy link

anwarx4u commented Jun 9, 2020

Try to cache clear:
php artisan route:clear

@uteq
Copy link

uteq commented Jul 30, 2020

@asivaneswaran Combining the above approach and using this solution I got this working: #64 (comment)

Let me know if you found a better solution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants