2

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.

Rupesh Terase
  • 440
  • 3
  • 14
  • 1
    have you added the IP address to the .env file? APP_URL= – Dave May 01 '20 at 17:28
  • @Dave I tried it but still it is redirecting me to localhost url. I also ran php artisan config:cache command to clear the cache after making changes to the .env file – Brainy Prb May 02 '20 at 06:26

0 Answers0