Welcome Guest, Not a member yet? Register   Sign In
API requests with a trailing forward slash
#1

(This post was last modified: 07-15-2020, 08:47 AM by ogomez.)

I spent a lot of time trying to figure out why my routes were not working and found that I needed to exclude the trailing forward slash. Not sure if this is done intentional but just wanted to bring this up in case someone else encounters this issue.

Routes:
PHP Code:
$routes->post('API/news''API\News::create');
$routes->get('API/news''API\News::view'); 

Example:
POST http://localhost/API/news/ will send you to the GET (http://localhost/API/news/view) route
POST http://localhost/API/news will work correctly

Even if I set my route with the trailing forward slash I still get routed to API\news::view. Any insight on this behavior appreciated.

Thanks in advance
Reply


Messages In This Thread
API requests with a trailing forward slash - by ogomez - 07-12-2020, 10:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB