After Laravel internal API call controller redirects to localhost

1.1k views Asked by At

I am using Laravel internal API calls, After internal call is complete i want to redirect to list page via same controller function. when i use redirect methods to redirect it redirects to http://localhost/ localhost should be IP address of website, I am running web-server on IP address

server run:

sudo php artisan serve --host=ip-address --port=8001

Laravel internal API call:

$roleApiRequest = Request::create($url,$method,$reqData);
$response = app()->handle($roleApiRequest);
$data = json_decode($response->getContent(),true);
$resStatus = $response->status();

This response contains data and after taking data i redirect to index page of module.

Redirect::route('roles.list');

It redirects to URL : http://localhost/roles (gives URL not found because actual URL is http://ip-address/roles)

return Redirect::back()->withInput($input); 

Redirect back works properly for previous urls but the back URL is not desired URL to redirect.

I think when call is made for internal API, Laravel replaces base URL with localhost for internal call and when we call redirect method it points to localhost.

I am using Dingo API for web-services.

Please help.

0

There are 0 answers