Post request to / doesnt work.
Created 6 years ago by gonziis

I have a single page website with a form in it. I would like the form to post to the same root (/), but it just doesn't do anything. Could be that Pyro is rewriting it? In routes directory web.php

Route::post('/', function() {
    return die(); //doesn't die, also tried just die() and all other stuff
});

Route::get('/', function () {
    return view('welcome');
});
ryanthompson  —  6 years ago

If you have a home page in the pages module then it's going to aggressively overtake the home page routing as it uses the any verb within the router.

ryanthompson  —  6 years ago

You could - however disable your home page (uncheck it) and manually route it for get only using the standard routing scheme for it - and route your post manually as well: https://github.com/anomalylabs/pages-module/blob/2.4/src/Page/Handler/PageHandlerExtension.php#L53-L61