For the past two days, I have been encountering a challenging issue with my Laravel application that is hosted on Heroku server. The app allows file uploads through an ajax request, displaying upload progress on the page and returning JSON response upon completion.
Despite setting Content-Type: application/json
and ensuring that X-CSRF-TOKEN
is valid in the header, after the upload is complete, instead of receiving the expected JSON response, the status is being set to 301 or 302, redirecting me to the home page.
When testing the Laravel app on my local server, it runs smoothly without any issues. I am now considering ways to pause Chrome before loading the redirection page by adding a breakpoint, allowing me to understand what exactly is happening prior to the redirection. I have attempted using the following code snippet in the console:
window.addEventListener("beforeunload", function() { debugger; }, false)
but unfortunately, this did not trigger a breakpoint. Any assistance on this matter would be greatly appreciated.