-
Laravel Version11.15.0 PHP Version8.2.12 Database Driver & VersionNo response DescriptionI have 2 controllers, 1 of them creates an api, simply pulls a member with a model and returns as a json response. ApiController works normally. And it returns json format. If I enter from the browser or send a request from postman it works very well. web.php
UserController.php
Admin/UserController.php
http://127.0.0.1:8000/api/users/11 When I open the API link with the browser, the response is: But if I go to admin/users/11 it goes into an infinite loop and give error.
Steps To ReproduceCreate 2 controllers and try to connect from one to the other with http:get. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@duran004, did you also test this behavior outside of using I could reproduce this behavior. With I didn't test whether A simpler rebuild of this case can be achieved with the following lines: <?php
Route::get('test', function() {
return response(Http::get(route('api.user'))->json());
});
Route::get('user', function() {
return response(json_encode(['name' => 'Max']));
})->name('api.user'); Please test it again with |
Beta Was this translation helpful? Give feedback.
@duran004, did you also test this behavior outside of using
php artisan serve
, which generally makes use of only one worker?I could reproduce this behavior. With
artisan serve,
you only have one PHP worker for a request. With your first request, you are blocking the single worker. This worker will try to access the URL given by theroute
function, which will return the full URL to the HTTP client, which then starts a new request. This request can not be processed byartisan serve
because the single worker is already occupied with your initial request. That means you don't have a bug; it is not an infinite loop. Your HTTP client is only waiting for your service to get a new free worker to…