php - Laravel temporary signed route not verifying correctly with domain
Get the solution ↓↓↓I'm working with one of my Laravel 8 projects, it's set up as an API on a sub-domain of my website and prefixed withapi.
.
Requests are made to my API on routes like the following: https://api.example.com/api/some-route, and the front-end of the website is on the standard https://example.com/, both of which live on the same server.
I'm trying to get theURL::temporarySignedRoute
to correctly verify and haven't been able to figure this out properly for weeks now.
My front-end requires a user to verify their email, so they click a button and a Laravel Job is dispatched, and a URL is generated:
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$team = isset($this->emailData['team_name']) ? $this->emailData['team_name'] : '';
// programatically set URL to be the api since APP_URL is https://example.com/
config(['app.url' => 'https://api.example.com//']);
// 4 hours until expiry, and secure URL
$verifyURL = URL::temporarySignedRoute(
'contact.verify', Carbon::now()->addHours(24), ['contact' => $notifiable['id'], 'team' => $team]
);
$data = [
'team_name' => $team,
'first_name' => $notifiable['first_name'],
'url' => $verifyURL
];
try {
$this->createHistoryEntry('mail', 'Verify Contact', $data, $notifiable);
} catch (\Exception $e) { }
return (new MailMessage)
->subject('Verify Email Address')
->markdown('emails.contacts.verify', $data);
}
The route looks like:
Route::get('email/contact/verify', 'VerifyContactsController@verifyContact')->name('contact.verify');
And when the user receives the email, the URL in the email is something like:
Now, for a starter, I need that URL to be the API, not the front-end, so why isn't the URL getting set to be the API despite setting my config?
How do I fix this?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: too few arguments to function laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.