来自远程连接的邮件上的Laravel 5令牌不匹配

时间:2015-10-03 13:38:23

标签: laravel exception post token mismatch

搜索了一整天,找不到答案 我正在使用php artisan serve -host:0.0.0.0运行我的服务器,因此我可以远程与我的服务器通信。 当我在我的localhost上测试一切正常时,但是当我尝试从远程设备发送一个post请求时,它正在响应TokenMismatchException。 贬低了这个小小的东西并缝制了我通过

发送的令牌
    <meta name="_token" id="token-input" content="{!! csrf_token() !!}"/>
function getToken(){
    return $('#token-input').attr('content');
}

//angular ajax
$http.post('/store', {id: 1,
            '_token': getToken()}).
            then(function (response) {
                ...
            },
            function (response) {
                $('body').html(response.data);
            });
当我的会话令牌不断变化时,

保持不变。 通过更改VerifyCsrfToken.php句柄方法来测试它来抛出

$token1 = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
throw new \App\Exceptions\SaleSiteException('token= ' . $token1 . '\nsession_token= ' . $request->session()->token());

我正在使用'files'驱动程序。试图将我的权限更改为framework / sessions文件夹,但没有运气。 顺便说一句,发送get请求正常。

1 个答案:

答案 0 :(得分:0)

app.controller('AboutController', function (..., something, ...) {
    // The data resolved by ui-router is ready when the controller is instantiated
}

可以找到文档here