2017-09-30 15:29
浏览 55


So I have an application that sends an AJAX request to an external server which does some stuff then makes a post call to the laravel application that made the initial call.

So I am trying to do a POST call to the laravel application. Now from the AJAX request i am sending the csrf_token()

Here are the headers I've put into my post request:

X-CSRF-TOKEN: LO8Dg7j1jZssXXGSLIa8inBgh2Y1QSsp6Birc1Ui
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded

That token belongs to the logged in user that made the AJAX request. Now the problem i'm getting is from this i get a TokenMismatchException500 error.

Is there something else I need to do in my external post calls headers in order to not encounter this error?

As i've got the CSRF token i am using a rest client to try send a test post using those headers and I get the same error?

The aim is on the recieving laravel app controller will then be able to use the token and i'll be able to use $request->user(); to get the user.

Note the recieving route has the web middleware attached to it.

图片转代码服务由CSDN问答提供 功能建议

所以我有一个应用程序向外部服务器发送一个AJAX请求,该服务器执行一些操作然后调用 初始调用的laravel应用程序。

所以我正在尝试对laravel应用程序进行POST调用。 现在从AJAX请求我发送 csrf_token()

以下是我在帖子请求中添加的标题: \ n

Content-Type:application / x-www-form-urlencoded 

该令牌属于发出AJAX请求的登录用户。 现在我得到的问题是从这里我得到 TokenMismatchException 500错误。

我的外部帖子调用标题中是否还需要做其他事情 为了不遇到这个错误?


目标是接收laravel app控制器然后将能够使用令牌,我将能够使用 $ request-> user(); 获取用户。

请注意,接收路由附有 web 中间件。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题