T
T
tioffs2018-07-01 14:53:33
Laravel
tioffs, 2018-07-01 14:53:33

Laravel route method post trailing slash gives error why?

Example:

/** Роутер */
Route::post('/news/life',  '[email protected]');

If we send a post request to site.com/news/life/
In response, we get the header: 301 Moved Permanently (and it will redirect us to GET: site.com/news/life )
And then we get:
/**
     * Throw a method not allowed HTTP exception.
     *
     * @param  array  $others
     * @return void
     *
     * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
     */
    protected function methodNotAllowed(array $others)
    {
        throw new MethodNotAllowedHttpException($others);
    }
 
    /**
     * Get routes from the collection by method.
     *
     * @param  string|null  $method
     * @return array
     */
    public function get($method = null)
    {
        return is_null($method) ? $this->getRoutes() : Arr::get($this->routes, $method, []);
    }
 
    /**
     * Determine if the route collection contains a given named route.

Arguments ""
Why is it throwing an exception? (Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
No message)
and not throwing a 404 page?
and for what reason is there a redirect with a slash at the end?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2018-07-01
@AXP-dev

You need to configure the server, it is he who redirects, and not Lara

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question