Laravel DecryptException-有效负载无效 [英] Laravel DecryptException - The payload is invalid
问题描述
我正在将AJAX发布请求发送回我的Laravel API,并收到此错误消息:
I am sending an AJAX post request back to my Laravel API and receiving this error messsage:
Compiled.php第13235行中的DecryptException: 有效负载无效.
DecryptException in compiled.php line 13235: The payload is invalid.
我正在从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屋!