hot-reload side effects seem to be clobbering my app |
Hi Team,
I am slowly losing the will ... I think the debug toolbar and tracing is very helpful but at the moment my app is not behaving as expected ie serving a login view when someone logs out after redirect. Looking at the FF java console I see messages like this: The connection to https://localhost/__hot-reload was interrupted while the page was loading. login line 37 > injectedScript:702:29 EventSource failed: error { target: EventSource, isTrusted: true, srcElement: EventSource, currentTarget: EventSource, eventPhase: 2, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, … } login line 37 > injectedScript:710:21 onerror https://localhost/login line 37 > injectedScript:710 (Async: EventHandlerNonNull) hotReloadConnect https://localhost/login line 37 > injectedScript:709 setHotReloadState https://localhost/login line 37 > injectedScript:697 init https://localhost/login line 37 > injectedScript:27 onreadystatechange https://localhost/?debugbar:49 (Async: EventHandlerNonNull) loadDoc https://localhost/?debugbar:14 (Async: EventListener.handleEvent) <anonymous> https://localhost/?debugbar:1 This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”. login XHRGET https://localhost/?debugbar_time=1747223756.436512 [HTTP/1.1 200 OK 78ms] XHRGET https://localhost/__hot-reload At this moment I am trying to redirect to "https//localhost/login" which I have successfully proved works when I initially login, but once I logout and redirect back to the same place I never see the login screen again. I am very frustrated and really cannot work out why. Any help would be appreciated, Thx, Paul
You can exclude any url's that are like login Controller etc.
CodeIgniter 4 User Guide - Except for a Few URIs What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Sorry I do not see the connection between the console errors I posted and your suggestion to filer my URL. My 3 to 4 migration just seems to get garder and harder.
05-15-2025, 12:35 PM
(This post was last modified: Yesterday, 03:29 PM by grimpirate. Edit Reason: Updated URL )
Can we assume you're using Shield? If so, have you changed anything from the default configuration? Shield automatically redirects you to the login page once you log out as seen here in the Auth.php configuration file. View an example here with the toolbar active and login/logout functioning as expected. The login is anon@anon.com:omgapassword
(05-15-2025, 12:35 PM)grimpirate Wrote: Can we assume you're using Shield? If so, have you changed anything from the default configuration? Shield automatically redirects you to the login page once you log out as seen here in the Auth.php configuration file. View an example here with the toolbar active and login/logout functioning as expected. The login is anon@anon.com:omgapassword Sorry - This is something else I know nothing about. I have checked my system folder and do not have a Shield folder. (BTW Your first link gave "Something has snapped"). I'm still no further on ......
I've updated the URL (should resolve the error that was displayed). What mechanism are you using for login/logout? Is this something you coded?
Try to disable Hot Reloading if you navigate to different pages.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Gents I really appreciate your time and efforts, so thx!
I have commented out "toolbar" in Filters and that has made no difference. Perhaps I can give you a little background which might help you to help me. The code was originally written over 10 years ago for our website. I inherited the code base and have supported it ever since. Under CI3 it all works really well. However one aspect of our site performs too slowly (big searches of a large table) and we now have a helper who loves Algolia. BUT to implement that we need to go to PHP8 (we were on 7.4). I have gallantly (perhaps foolishly) taken on the upgrades and bitten the CI4 task to future proof the site. I have some of it working but keep on tripping up on things that at first sight should be simple. (PS We did code our own login and logout which worked fine in CI3) Redirection seems to be very mysterious. The upgrade guide suggests replacing all my original redirects with redirect()->to, which I have done. But as it stands today I have 2 big redirect issues: 1) When I "redirect()->to('logout') the routes entry says run "User::logout" which then calls a model UserAuthenticateModel to actually send messages, close sessions and finally redirect()->to('login'). This simply doesn't work and I end up with a blank screen instead of the login view. I also notice that the url remains at "https://localhost/logout" 2) A similar problem happens when I get to a dialog for uploading a file. The view gets displayed fine, loads of JS files manage the upload with a php Library. I then present a "next" button which post the data to a form "action". This should go back to the controller which then builds and displays the next view for the user to configure more stuff. BUT it doesn't somehow find or run the route and simply reproduces the same image upload view. Am I missing a fundamental CI4 design pattern here? Do all redirects have to be from a controller perhaps? Do I need to pass something extra in the Model constructor parms? I notice the docs suggest using redirect()->route for named routes. Is that different to to()? How crucial is the leading '/'. I have gone round in endless loops trying alternatives and still haven't solved my issues. So if you can suggest where to go next that would be good. I'm sure if we were to rewrite the whole app with CI4 in mind it would look a bit different, but I sadly don't have the time or energy for that commitment. Regards Paul |
Welcome Guest, Not a member yet? Register Sign In |