I am trying to initiate a function when the user clicks on action, the function will redirect the page to the external domain page for verification of data and return a response from there back to the Laravel page,
public function connect($id)
{
$data = Api::where('id', $id)->first();
return redirect()->away('https://api.xxx.com/login/dialog')->with([
'client_id' => $data->api_key,
'redirect_uri' => $data->redirect_uri,
'response_type' => 'code'],
);
}
Now, the external page does not see this array of data, So the question is how can I pass data to the external page for API verification and back to the original redirect page for further processing?
>Solution :
Laravel redirect()->away() can only make GET requests and not POST request. In order to attach the query parameters you can take the following approaches:
return redirect()->away('https://example.com?param1=value1');
OR
$param1 = 'value1';
$url = 'https://example.com?param1=' . urlencode($param1);
return redirect()->away($url);