After having setup my first October installation successfully I'm now sneaking into the details. First thing I wanted to try: Route every backend request over SSL. In Laravel this easy: Just define a filter and execute it as a 'before' filter e.g. by calling it in a Route::group block:
// define the filter in app/filters.php
Route::filter('forceSSL', function() {
if(app()->env == 'production') {
if(!Request::secure()) {
return Redirect::secure(Request::getRequestUri());
}
}
});
// inject into the routing e.g. in Route::group
Route::group(['before' => 'forceSSL'], function() {
Route::get('signup', 'UsersController@create');
/* ... more routes ... */
});
This doesn't seem to work like this e.g. with routes defined for the backend (modules/backend/routes.php). Adding a custom filter in app/filters.php and injecting it in as a 'before' within modules/backend/routes.php doesn't have any effect:
// Register Backend routes before all user routes.
App::before(function($request) {
Route::group(['before' => 'forceSLL', 'prefix' => Config::get('cms.backendUri', 'backend')], function() {
Route::any('{slug}', 'Backend\Classes\BackendController@run')->where('slug', '(.*)?');
});
// ....
});
How can I handle rouing over SSL in October?
Thanks, Stefan
Last updated