stoi2m1's avatar

Error 405 with Email Verification and Vue Front End

As I understand it an email verification should happen when the user is logged into Laravel. Since I am using Vue as my front end I do not want to require the user to be logged in when I verify their email. In the construct function of the Verification Controller there were some lines of code adding additional guards to my verify route ( ie signed, auth and throttle). I commented them and now when I run the command php artisan route:list and it shows my route looks like this.

| | POST | api/auth/verify/{email-token} | | App\Http\Controllers\Auth\VerificationController@verify | api |

However, I am getting an error 405, Method Not Allowed. Any ideas what else could be causing my route to not be allowed to this method?

0 likes
5 replies
stoi2m1's avatar

I have a working .env file can you elaborate what specifically in the .env file I need to configure?

jeevamugunthan's avatar

yeah in your .env file you need to set the following items

MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null

these are default given host and port etc..

u need to change this with your own host and port etc..

stoi2m1's avatar

I am using telescope to catch the email and access the created link. When I click on the link I get a 405 error when my front end tries to POST to the /api/auth/verify/{emailToken} route.

Are you saying this route will not work without a mail server being configured?

stoi2m1's avatar
stoi2m1
OP
Best Answer
Level 1

It appears my route was the issue. Route parameters are not allowed to contain a hyphen (-).

Quote from the Laravel Docs. https://laravel.com/docs/5.8/routing#required-parameters

"Route parameters are always encased within {} braces and should consist of alphabetic characters, and may not contain a - character."

Please or to participate in this conversation.