Welcome Guest, Not a member yet? Register   Sign In
routes not recognized after Post
#1

Hi all,

Since a few months I've been using CI4 for some projects and, in all honesty, Im very satisfied. 

However, I'm struggling with an issue I just can't figure out. 

When I navigate to a page in the application using regular links all works fine.  The routes are initializing perfectly.  When I do a post to the same page, the post is received and processed properly but when rendering the page, the routes are seemingly unknown. 

Please find below the message i get which seems to say that the routes are not valid.  (but like i said, when i navigate to the page with regular links, the routes are initialized perfectly.

----------------------------------------------------------------------------------------------
Unable to locate a valid route.


BASEPATH/Router\RouteCollection.php at line 950

Code:
throw new \InvalidArgumentException('Unable to locate a valid route.');

----------------------------------------------------------------------------------------------
Reply
#2

You should post what your route list looks like
Reply
#3

After some further researche I found that only the "post" and "add" routes are checked.  so I switched all the verb defined routes (get-post) to regular "add" definitions and it works.  Im not sure if this is supposed to work like this or if this is a bug.  Why the possibility to use verbs in route definitions if they cant be resolved after a post? 

in any case, my problem is solved like this,

thx fr the input.
Reply
#4

@LVD - Are you using the latest version of the code? At one time it would only save the routes for the current request method (POST in your case) and ignore the others. This was attempting to optimize the process a little, but turned out to be ill-advised as you can imagine. Smile That should be fixed in newer versions, though.
Reply
#5

(03-25-2018, 03:01 AM)LVD Wrote: After some further researche I found that only the "post" and "add" routes are checked.  so I switched all the verb defined routes (get-post) to regular "add" definitions and it works.  Im not sure if this is supposed to work like this or if this is a bug.  Why the possibility to use verbs in route definitions if they cant be resolved after a post? 

in any case, my problem is solved like this,

thx fr the input.

I remember this happens with a test project here. In my case, there were two similar routes /admin /blog/posts/(:num) and /blog/posts/(:num).

When I updated a post on a POST only route (/admin/blog/posts/(:num)/update), I redirected it back to the edit page (/admin/blog/posts/(:num)). But strangely, it was sometimes redirected to the public post page. I figured there must be some conflict over the similarity in the path of the routes, but, by the way, it must be because of HTTP methods then as @kilishan said:

(03-25-2018, 07:54 PM)kilishan Wrote: @LVD - Are you using the latest version of the code? At one time it would only save the routes for the current request method (POST in your case) and ignore the others. This was attempting to optimize the process a little, but turned out to be ill-advised as you can imagine. Smile That should be fixed in newer versions, though.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB