R
R
Ruslan Absalyamov2020-01-01 21:13:35
Yii
Ruslan Absalyamov, 2020-01-01 21:13:35

Why is the page or data not displayed on post request with rest api?

I have config in api/config/main.php

'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing' => true,
            'showScriptName' => false,
            'rules' => [
          [
                    'class' => 'yii\rest\UrlRule',
                    'controller' => ['v1/auth'],
                    'pluralize' => false,
                    'extraPatterns' => [
                        'POST auth' => 'auth/index',
                    ]
                ],
            ],
        ],

But in this situation, in a get request, it normally works for me, but with a post request, it already gives a 404 error code.
namespace api\modules\v1\controllers;

class AuthController extends ApiController
{
    /**
     * @brief Авторизация
     */
    public function actionIndex()
    {
        var_dump("hello"); die();
    }
}

Why exactly such an incomprehensible event occurs?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question