F
F
frontendo2017-04-23 18:41:09
Laravel
frontendo, 2017-04-23 18:41:09

How to correctly make routing based on the values ​​passed in the POST request?

Hello coding masters!
I want to make routing for SPA based on the parameters passed in the POST request so that it is not visible to prying eyes which addresses are requested by the user when using the application. After a little thought, I made such a completely workable option, with the exception of the impossibility of using redirects between routes

Route::group([
    'prefix'     => 'api',
    'namespace'  => 'Api',
], function () {

    $actions = [
        'login' => '[email protected]',
        'logout' => '[email protected]',
        'authCurrent' => '[email protected]'
    ];

    $act = request()->input('act');

    $action = isset($actions[$act]) ? $actions[$act] : '[email protected]';

    Route::post('', $action);

});

The solution though works, but I doubt its correctness. Can anyone suggest a better option?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-04-23
@Sanasol

Of course, I'm not an expert, but devtools show everything all of a sudden.
What is this "protection" from?
You can make it difficult for yourself in simpler ways.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question