Laravel上来自外部服务器的POST问题 [英] POST from external server issue on Laravel
本文介绍了Laravel上来自外部服务器的POST问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从外部服务器向我的Laravel应用发布信息,它在app/filters/policy.php
:Illuminate\Session\TokenMismatchException
上抛出此异常.
I am doing a post from an external server to my Laravel app and it is throwing this exception on app/filters/policy.php
: Illuminate\Session\TokenMismatchException
.
这是我的app/filters/policy.php
:
Route::filter('csrf', function()
{
$token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token');
if (Session::token() != $token)
{
throw new Illuminate\Session\TokenMismatchException;
}
});
这是我的app/route.php
:
Route::any('webservice', ['uses' => 'WebserverController@postWebservice']);
我认为这是因为CSRF过滤器应用于所有路由,但我不知道如何将其禁用到/webservice
.
I think it is because the CSRF filter is applied to all routes, but I don't know how to disable it to /webservice
.
我将不胜感激.
推荐答案
也许您可以尝试以下方法:
Maybe you may try something like this:
if(Request::url() != 'http://example.com//webservice') {
$token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token')
if (Session::token() != $token) {
throw new Illuminate\Session\TokenMismatchException;
}
}
这篇关于Laravel上来自外部服务器的POST问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文