douzen1896 2016-10-08 13:41
浏览 247
已采纳

切换服务器后,Laravel CsrfToken将在刷新时到期

I know my issue is not because of Laravel but most likely the php configuration (sessions), but I am not sure what to check. I was running this particular project on a homestead and it was fine. Now after I submit a form (it's a steps controller, post form -> go to step 2 etc.) and refresh the page my csrf token is invalid.

I thought it was because of session lifetime and such or generation of new token, but no .. the token is the same, but I still get TokenMismatchException after I refresh the page.

The environment is pretty much the same as the homestead (nginx (latest), php(5.6, I don't know what homestead had) ). The logins work fine, I stay logged in while browsing, but when I go through the steps this happens ..

Problem & Solution:

As per comments bellow where I forgot to update, I found out the problem was actually the fact, that the dev server was forced through cloudflare, but the base url in Laravel was left at http://... - I just added to AppServiceProvider

$this->app['request']->server->set('HTTPS', true);

and it wasn't doing the verification error.

  • 写回答

2条回答 默认 最新

  • doufu6423 2016-10-09 07:19
    关注

    As per comments bellow where I forgot to update, I found out the problem was actually the fact, that the dev server was forced through cloudflare, but the base url in Laravel was left at http://... - I just added to AppServiceProvider

     $this->app['request']->server->set('HTTPS', true);
    

    and it wasn't doing the verification error.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口