laravel / fortify

Backend controllers and scaffolding for Laravel authentication.
https://laravel.com/docs/fortify
MIT License
1.61k stars 294 forks source link

Strange NotFoundHttpException when trying to perform register action #156

Closed Filip785 closed 3 years ago

Filip785 commented 3 years ago

Description:

I'm trying to use Fortify as an API authentication for my React app, but attempting to use the /register route more then once throws the NotFoundHttpException. Basically, the first time I use the /register route (passing correct JSON to register the user) it will work, validate & add the data to the database, the next time I try it will throw an NotFoundHttpException. I tried to clear routes cache, app cache etc but it didn't help at all. Same issue happens again. If I remove the project and recreate it, same thing happens.

The weird part in all of this is if I try to make GET request to this API route it will tell me that this action is not supported (meaning that it exists but cannot do GET on it), but the POST request will give me NotFoundHttpException (meaning it doesn't exist at all?). I also ran php artisan route:list and the /register route is showing with correct method - POST.

Am I missing something?

Steps To Reproduce:

  1. Create fresh Laravel project
  2. Add Fortify to it with composer require laravel/fortify
  3. Publish Fortify resources with php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"
  4. Migrate the database with php artisan migrate
  5. Set 'views' => false in fortify.php (since I'm using Fortify as API only)
  6. Add FortifyServiceProvider to app.php providers array
  7. Try to run an POST request to /register route through API client such as Insomnia or Postman
  8. First time it works & adds data to database, second time it throws NotFoundHttpException

EDIT: I figured out that this happens because as soon as registration is done, I get "logged in" as well, thus it returns this exception. If I make a POST to /logout and try to register again it works as expected.

driesvints commented 3 years ago

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.