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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器