Redirecting back to original Angular.js destination from Laravel Auth

Posted: 2014-11-21 21:24:58


You can see in the comments some updated info.

When a user visits an Angular url (not html5) like

Then gets redirected to because they are not logged in. It would be nice to send them right back after that.

These steps will make that possible.

Include this file in your authentication page.

    'use strict';

    var intended = window.location.hash;
    (intended.length > 0) ? jQuery.cookie('intended', '/app' + intended) : jQuery.cookie('intended', '/app');


Then add this library to your app jquery.cookies.js and load that, this script and of course jquery.

Finally after an successful auth add this

return Redirect::to($_COOKIE['intended']);

Laravel 4.2 = app/controllers/AuthController.php:61

Laravel 5 = app/Http/Controllers/AuthController.php:52