Skip to content
Advertisement

Laravel 8 customise email verification link

I am writing an API using Laravel 8 .. I have followed the documentation for implementing email verification, but I want to modify the link that is sent with the email.

My API and Frontend are completely seperate, so the link that Laravel creates needs to be changed to point to my frontend.

I have implemented as per in my AuthServiceProvider;

JavaScript

I am working on localhost so please excuse the URL’s .. But the URL that laravel outputs is as follows;

JavaScript

I need to change that to something like;

JavaScript

Is that possible at all?

Cheers,

Advertisement

Answer

As per the documentation, you need to set up a route with a specific naming convention; verification.verify.

You can add this route to your web routes like so:

JavaScript

Laravel doesn’t care that the actual frontend is detached for parsing the link.

Second, you need to verify the request via your API from your detached frontend. You need to forward the request to the API and use the IlluminateFoundationAuthEmailVerificationRequest as the Request instance to fulfill the verification.

The following example is just a pseudo example, as this might require some tinkering depending on your frontend implementation, but you would hopefully get the idea. This route of course belongs to your api routes.

JavaScript

That should do it.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement