From 958948d75fadcf66c9c20ccc3699ffec1fdb02e5 Mon Sep 17 00:00:00 2001 From: Alexandr Chernyaev Date: Sat, 23 Nov 2024 05:24:42 +0300 Subject: [PATCH] Fixed csrf token loading for axios after login --- resources/js/controllers/html_load_controller.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/js/controllers/html_load_controller.js b/resources/js/controllers/html_load_controller.js index 6b2956b9b..b225cb215 100644 --- a/resources/js/controllers/html_load_controller.js +++ b/resources/js/controllers/html_load_controller.js @@ -8,6 +8,12 @@ export default class extends ApplicationController { initialize() { this.axios(); this.csrf(); + + /** + * Ensures the CSRF token is updated for pages that were reloaded, + * such as when a user logs into the system. + */ + window.addEventListener('turbo:load', () => this.csrf()); } /**