【发布时间】:2019-02-19 06:11:59
【问题描述】:
我有一个网站,当提交帖子时,它会转到安装了 laravel 的外部网站。我在网站上有一个通用表单,提交后我不断收到 laravel 中的 419 错误。我在VerifyCsrfToken中添加了url,还是不行。
/app/Http/Middleware/VerifyCsrfToken.php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
*
* @var bool
*/
protected $addHttpCookie = true;
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'https://pharaohmfg.com/collections/*'
];
}
web.php
Route::get('/', 'PostController@index')->name('home.index');
Route::post('callback', 'PostController@callback')->name('callback.post');
postController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PostController extends Controller
{
public function index(Request $request)
{
return redirect()->away('http://pharaohmfg.com');
}
public function callback(Request $request)
{
return $request->all();
}
}
我做错了什么?网址是https://pharaohmfg.com/collections/billiard-pool-tables/products/siamun-pool-table
【问题讨论】:
-
你的路线有名字吗?我认为您需要使用
$except属性的名称。 -
另外,
$except应该是被排除的路由(端点)。 -
我不明白你在说什么
-
你的路线有名字吗?你能告诉我你的
routes/web.php吗? -
你应该在 $except 数组中添加
/callback