From 58cce365cb4580e106a18405380499086cc97ec6 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 27 Nov 2024 08:26:43 +0100 Subject: [PATCH] Configure axios headers and stateful API. --- bootstrap/app.php | 2 +- resources/js/bootstrap.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index d654276..ae59fec 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -12,7 +12,7 @@ return Application::configure(basePath: dirname(__DIR__)) health: '/up', ) ->withMiddleware(function (Middleware $middleware) { - // + $middleware->statefulApi(); }) ->withExceptions(function (Exceptions $exceptions) { // diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index 5f1390b..530b129 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -1,4 +1,8 @@ import axios from 'axios'; + window.axios = axios; +window.axios.defaults.baseURL = import.meta.env.VITE_APP_URL; window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; +window.axios.defaults.headers.common['X-CSRF-Token'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); +window.axios.defaults.withCredentials = true;