Laravel DecryptException - 负载无效 [英] Laravel DecryptException - The payload is invalid

查看:37
本文介绍了Laravel DecryptException - 负载无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向我的 Laravel API 发送 AJAX 发布请求并收到此错误消息:

I am sending an AJAX post request back to my Laravel API and receiving this error messsage:

compiled.php 第 13235 行中的 DecryptException:负载无效.

我正在从 cookie 中读取 XSRF-TOKEN 并将其作为名为 X-XSRF-TOKEN 的请求标头发送.

I am reading the XSRF-TOKEN from the cookie and sending that along as a request header named X-XSRF-TOKEN.

该站点是一个完全独立于 Laravel API 的站点,但共享相同的会话,这就是我从 cookie 中获取值的原因.

The site is a completely seperate site from the Laravel API but shares the same session, which is why I am getting the value from a cookie.

奇怪的是,有时它会起作用.任何想法是什么导致这种情况?

The strange thing is, occasionally it works. Any ideas what is causing this?

推荐答案

如果您从 JavaScript 发送 X-XSRF-TOKEN,您可以使用 decodeURIComponent() 对其进行解码.它将 %3D 转换为 =.

If you are sending X-XSRF-TOKEN from JavaScript you can decode it using decodeURIComponent(). It converts %3D to =.

这篇关于Laravel DecryptException - 负载无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆