Laravel 5.4 inconsistent no response and no error in logs2019 Community Moderator ElectionHow do I get PHP errors to display?How do I set up middleware in laravelAuth::user() returns nullHow do I use the / (index) route twice for both logged in and logged out?Laravel 5.2 - access authenticated user in route bindingLaravel 5.4 redirect to specific page if user is not authenticated using middlewareLaravel 5.4 Auth API routeLaravel 5.6 - How to get auth()->user() or $response->user() in api controller?Laravel: how to get current user in public routeLaravel 5.6.28: Auth Middleware redirects to Login (handle not called)

Too soon for a plot twist?

Professor forcing me to attend a conference, I can't afford even with 50% funding

After Brexit, will the EU recognize British passports that are valid for more than ten years?

Why does a car's steering wheel get lighter with increasing speed

Is it appropriate to ask a former professor to order a library book for me through ILL?

Short story about cities being connected by a conveyor belt

What does it take to become a wilderness skills guide as a business?

Interpretation of linear regression interaction term plot

Sort array by month and year

Where is the License file location for Identity Server in Sitecore 9.1?

Limpar string com Regex

Is this Paypal Github SDK reference really a dangerous site?

How can I have x-axis ticks that show ticks scaled in powers of ten?

Are small insurances worth it?

Should I file my taxes? No income, unemployed, but paid 2k in student loan interest

Cycles on the torus

Will the concrete slab in a partially heated shed conduct a lot of heat to the unconditioned area?

Should I apply for my boss's promotion?

Inorganic chemistry handbook with reaction lists

Why do we call complex numbers “numbers” but we don’t consider 2-vectors numbers?

Can I negotiate a patent idea for a raise, under French law?

Was it really inappropriate to write a pull request for the company I interviewed with?

Issue with units for a rocket nozzle throat area problem

Generating a list with duplicate entries



Laravel 5.4 inconsistent no response and no error in logs



2019 Community Moderator ElectionHow do I get PHP errors to display?How do I set up middleware in laravelAuth::user() returns nullHow do I use the / (index) route twice for both logged in and logged out?Laravel 5.2 - access authenticated user in route bindingLaravel 5.4 redirect to specific page if user is not authenticated using middlewareLaravel 5.4 Auth API routeLaravel 5.6 - How to get auth()->user() or $response->user() in api controller?Laravel: how to get current user in public routeLaravel 5.6.28: Auth Middleware redirects to Login (handle not called)










0















IMPORTANT EDIT: I cannot seem to be able to replicate the issue on Chrome, it is intermittent on Firefox (about 50/50). And is happening even more on Edge (about 70/30).



I have checked other similar questions but they do not resolve the issue.



I am using Angular JS with Laravel 5.4, sending a GET request and it is sometimes succeeding and sometimes failing. When I say failing I mean I am literally getting nothing back. I am getting no error and I can confirm laravel.log file is logging other errors but nothing for this.



In my console I have two examples that were done one after the other.



The request is called get-user-roles and the function is called at UserController@getUserRoles



Failed:
enter image description here



Succeeded:
enter image description here
You can see in the second one I am getting blank data back as expected.



Here is my web.php in /routes



Route::group(
[
'middleware' => ['cors', 'switchdb'],

], function ()

// auth

Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController@authenticate');

Route::group(
[
'middleware' => ['jwt.auth'],

], function ()
Route::get('get-user-roles', 'UserController@getUserRoles');
);

Route::group(
[
'middleware' => ['jwt.auth', 'is-not-customer'],

], function ()
// more functions
);
);


Here is my controller UserController



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppUser;
use AppRole;
use AppHttpRequestsPublishUserRequest;
use AppHttpRequestsChangePasswordRequest;
use Auth;


class UserController extends Controller


protected $user;

public function __construct()

$this->user = new User();


public function getUserRoles()

try
$roles = $this->user->getPagesForRoles(Auth::user()->id);
foreach ($roles as $key => $role)
if ($role['hasRole'] == 0)
unset($roles[$key]);



return response()->json([
'data' => $roles
], 200
);

catch (Exception $e)
return response()->json([
'message' => $e->getMessage(),
'line' => $e->getLine()
], 400
);





And my model code (AppUser) for obtaining the roles...



public function getPagesForRoles($userID = false)

if (!$userID)
$userID = Auth::user()->id;


$pagesForRoles = $this->role->getRoles();

// check if user has role or not and add it to data
if ($userID != 0)

foreach ($pagesForRoles as $key => &$role)
$hasRole = DB::table('user_roles')
->where('role_id', '=', $key)
->where('user_id', '=', $userID)
->get();

if (isset($hasRole[0]))
if($key == 'admin')
$hasAdminRole = 1;

$role['hasRole'] = 1;
else
$role['hasRole'] = 0;




if($userID == 1


getRoles() that is called in the model code simply returns a hardcoded array.



EDIT: Its worth mentioning that when I do die('test'); in my controller function I do get a response every time.










share|improve this question
























  • Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

    – Daniel Protopopov
    Oct 16 '18 at 19:27






  • 1





    Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

    – Adrian
    Oct 17 '18 at 9:18











  • The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

    – Niraj Shah
    Oct 17 '18 at 13:22











  • Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

    – Adrian
    Oct 17 '18 at 14:41











  • This isnt happening in Chrome for some reason, only Firefox and Edge.

    – Adrian
    Oct 18 '18 at 14:39















0















IMPORTANT EDIT: I cannot seem to be able to replicate the issue on Chrome, it is intermittent on Firefox (about 50/50). And is happening even more on Edge (about 70/30).



I have checked other similar questions but they do not resolve the issue.



I am using Angular JS with Laravel 5.4, sending a GET request and it is sometimes succeeding and sometimes failing. When I say failing I mean I am literally getting nothing back. I am getting no error and I can confirm laravel.log file is logging other errors but nothing for this.



In my console I have two examples that were done one after the other.



The request is called get-user-roles and the function is called at UserController@getUserRoles



Failed:
enter image description here



Succeeded:
enter image description here
You can see in the second one I am getting blank data back as expected.



Here is my web.php in /routes



Route::group(
[
'middleware' => ['cors', 'switchdb'],

], function ()

// auth

Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController@authenticate');

Route::group(
[
'middleware' => ['jwt.auth'],

], function ()
Route::get('get-user-roles', 'UserController@getUserRoles');
);

Route::group(
[
'middleware' => ['jwt.auth', 'is-not-customer'],

], function ()
// more functions
);
);


Here is my controller UserController



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppUser;
use AppRole;
use AppHttpRequestsPublishUserRequest;
use AppHttpRequestsChangePasswordRequest;
use Auth;


class UserController extends Controller


protected $user;

public function __construct()

$this->user = new User();


public function getUserRoles()

try
$roles = $this->user->getPagesForRoles(Auth::user()->id);
foreach ($roles as $key => $role)
if ($role['hasRole'] == 0)
unset($roles[$key]);



return response()->json([
'data' => $roles
], 200
);

catch (Exception $e)
return response()->json([
'message' => $e->getMessage(),
'line' => $e->getLine()
], 400
);





And my model code (AppUser) for obtaining the roles...



public function getPagesForRoles($userID = false)

if (!$userID)
$userID = Auth::user()->id;


$pagesForRoles = $this->role->getRoles();

// check if user has role or not and add it to data
if ($userID != 0)

foreach ($pagesForRoles as $key => &$role)
$hasRole = DB::table('user_roles')
->where('role_id', '=', $key)
->where('user_id', '=', $userID)
->get();

if (isset($hasRole[0]))
if($key == 'admin')
$hasAdminRole = 1;

$role['hasRole'] = 1;
else
$role['hasRole'] = 0;




if($userID == 1


getRoles() that is called in the model code simply returns a hardcoded array.



EDIT: Its worth mentioning that when I do die('test'); in my controller function I do get a response every time.










share|improve this question
























  • Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

    – Daniel Protopopov
    Oct 16 '18 at 19:27






  • 1





    Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

    – Adrian
    Oct 17 '18 at 9:18











  • The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

    – Niraj Shah
    Oct 17 '18 at 13:22











  • Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

    – Adrian
    Oct 17 '18 at 14:41











  • This isnt happening in Chrome for some reason, only Firefox and Edge.

    – Adrian
    Oct 18 '18 at 14:39













0












0








0








IMPORTANT EDIT: I cannot seem to be able to replicate the issue on Chrome, it is intermittent on Firefox (about 50/50). And is happening even more on Edge (about 70/30).



I have checked other similar questions but they do not resolve the issue.



I am using Angular JS with Laravel 5.4, sending a GET request and it is sometimes succeeding and sometimes failing. When I say failing I mean I am literally getting nothing back. I am getting no error and I can confirm laravel.log file is logging other errors but nothing for this.



In my console I have two examples that were done one after the other.



The request is called get-user-roles and the function is called at UserController@getUserRoles



Failed:
enter image description here



Succeeded:
enter image description here
You can see in the second one I am getting blank data back as expected.



Here is my web.php in /routes



Route::group(
[
'middleware' => ['cors', 'switchdb'],

], function ()

// auth

Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController@authenticate');

Route::group(
[
'middleware' => ['jwt.auth'],

], function ()
Route::get('get-user-roles', 'UserController@getUserRoles');
);

Route::group(
[
'middleware' => ['jwt.auth', 'is-not-customer'],

], function ()
// more functions
);
);


Here is my controller UserController



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppUser;
use AppRole;
use AppHttpRequestsPublishUserRequest;
use AppHttpRequestsChangePasswordRequest;
use Auth;


class UserController extends Controller


protected $user;

public function __construct()

$this->user = new User();


public function getUserRoles()

try
$roles = $this->user->getPagesForRoles(Auth::user()->id);
foreach ($roles as $key => $role)
if ($role['hasRole'] == 0)
unset($roles[$key]);



return response()->json([
'data' => $roles
], 200
);

catch (Exception $e)
return response()->json([
'message' => $e->getMessage(),
'line' => $e->getLine()
], 400
);





And my model code (AppUser) for obtaining the roles...



public function getPagesForRoles($userID = false)

if (!$userID)
$userID = Auth::user()->id;


$pagesForRoles = $this->role->getRoles();

// check if user has role or not and add it to data
if ($userID != 0)

foreach ($pagesForRoles as $key => &$role)
$hasRole = DB::table('user_roles')
->where('role_id', '=', $key)
->where('user_id', '=', $userID)
->get();

if (isset($hasRole[0]))
if($key == 'admin')
$hasAdminRole = 1;

$role['hasRole'] = 1;
else
$role['hasRole'] = 0;




if($userID == 1


getRoles() that is called in the model code simply returns a hardcoded array.



EDIT: Its worth mentioning that when I do die('test'); in my controller function I do get a response every time.










share|improve this question
















IMPORTANT EDIT: I cannot seem to be able to replicate the issue on Chrome, it is intermittent on Firefox (about 50/50). And is happening even more on Edge (about 70/30).



I have checked other similar questions but they do not resolve the issue.



I am using Angular JS with Laravel 5.4, sending a GET request and it is sometimes succeeding and sometimes failing. When I say failing I mean I am literally getting nothing back. I am getting no error and I can confirm laravel.log file is logging other errors but nothing for this.



In my console I have two examples that were done one after the other.



The request is called get-user-roles and the function is called at UserController@getUserRoles



Failed:
enter image description here



Succeeded:
enter image description here
You can see in the second one I am getting blank data back as expected.



Here is my web.php in /routes



Route::group(
[
'middleware' => ['cors', 'switchdb'],

], function ()

// auth

Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController@authenticate');

Route::group(
[
'middleware' => ['jwt.auth'],

], function ()
Route::get('get-user-roles', 'UserController@getUserRoles');
);

Route::group(
[
'middleware' => ['jwt.auth', 'is-not-customer'],

], function ()
// more functions
);
);


Here is my controller UserController



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppUser;
use AppRole;
use AppHttpRequestsPublishUserRequest;
use AppHttpRequestsChangePasswordRequest;
use Auth;


class UserController extends Controller


protected $user;

public function __construct()

$this->user = new User();


public function getUserRoles()

try
$roles = $this->user->getPagesForRoles(Auth::user()->id);
foreach ($roles as $key => $role)
if ($role['hasRole'] == 0)
unset($roles[$key]);



return response()->json([
'data' => $roles
], 200
);

catch (Exception $e)
return response()->json([
'message' => $e->getMessage(),
'line' => $e->getLine()
], 400
);





And my model code (AppUser) for obtaining the roles...



public function getPagesForRoles($userID = false)

if (!$userID)
$userID = Auth::user()->id;


$pagesForRoles = $this->role->getRoles();

// check if user has role or not and add it to data
if ($userID != 0)

foreach ($pagesForRoles as $key => &$role)
$hasRole = DB::table('user_roles')
->where('role_id', '=', $key)
->where('user_id', '=', $userID)
->get();

if (isset($hasRole[0]))
if($key == 'admin')
$hasAdminRole = 1;

$role['hasRole'] = 1;
else
$role['hasRole'] = 0;




if($userID == 1


getRoles() that is called in the model code simply returns a hardcoded array.



EDIT: Its worth mentioning that when I do die('test'); in my controller function I do get a response every time.







php angularjs laravel laravel-5 laravel-5.4






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 18 '18 at 16:39







Adrian

















asked Oct 16 '18 at 18:53









AdrianAdrian

1,04332574




1,04332574












  • Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

    – Daniel Protopopov
    Oct 16 '18 at 19:27






  • 1





    Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

    – Adrian
    Oct 17 '18 at 9:18











  • The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

    – Niraj Shah
    Oct 17 '18 at 13:22











  • Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

    – Adrian
    Oct 17 '18 at 14:41











  • This isnt happening in Chrome for some reason, only Firefox and Edge.

    – Adrian
    Oct 18 '18 at 14:39

















  • Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

    – Daniel Protopopov
    Oct 16 '18 at 19:27






  • 1





    Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

    – Adrian
    Oct 17 '18 at 9:18











  • The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

    – Niraj Shah
    Oct 17 '18 at 13:22











  • Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

    – Adrian
    Oct 17 '18 at 14:41











  • This isnt happening in Chrome for some reason, only Firefox and Edge.

    – Adrian
    Oct 18 '18 at 14:39
















Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

– Daniel Protopopov
Oct 16 '18 at 19:27





Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

– Daniel Protopopov
Oct 16 '18 at 19:27




1




1





Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

– Adrian
Oct 17 '18 at 9:18





Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

– Adrian
Oct 17 '18 at 9:18













The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

– Niraj Shah
Oct 17 '18 at 13:22





The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

– Niraj Shah
Oct 17 '18 at 13:22













Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

– Adrian
Oct 17 '18 at 14:41





Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

– Adrian
Oct 17 '18 at 14:41













This isnt happening in Chrome for some reason, only Firefox and Edge.

– Adrian
Oct 18 '18 at 14:39





This isnt happening in Chrome for some reason, only Firefox and Edge.

– Adrian
Oct 18 '18 at 14:39












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52842199%2flaravel-5-4-inconsistent-no-response-and-no-error-in-logs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52842199%2flaravel-5-4-inconsistent-no-response-and-no-error-in-logs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme