Laravel get intended url

javascript, laravel, php

Solution

In your controller action use:

`$url = Redirect::intended( ... )->getTargetUrl();`

(Where `...` is the fallback url)

Then return it in the JSON response, and use `window.location` or other to do the redirect.

Problem

I use a common httpRequest to login, so I could use `Redirect::intended();` to lead the user to a url before them being lead to the login page. That all works well. Now I've changed login to ajax request I can only redirect the url in javascript now. So I've to pass the intended url to front end then do the `window.location=url` The problem is I can't get the `intended/origina`l url. Can any kind laravel expert help me out ?

Original source