Merge branch 'csrf-header' into 'boutique-sable'

add axios csrf header for re7 and production servers

See merge request service-web-lab/boutique-cnc-sable!6
This commit is contained in:
Alexis Gousseau 2022-10-12 13:31:23 +00:00
commit 932c88b57b
2 changed files with 15 additions and 1 deletions

View file

@ -62,6 +62,20 @@ const store = new Vuex.Store({
}
});
const metaCSRFToken = document.querySelector(
"meta[name='csrf-token']"
)
if (!metaCSRFToken) {
throw new Error("Missing meta CSRF token");
}
Axios.defaults.headers.common = {
Accept: "application/json, text/plain, */*",
"X-Requested-With": "XMLHttpRequest",
"X-CSRF-TOKEN": metaCSRFToken.getAttribute("content"),
};
window.axios = Axios;
const app = new Vue({

View file

@ -26,7 +26,7 @@
<link rel="canonical" href="{{ url()->current() }}" />
<!-- CSRF Token -->
<meta name="csrf-token" content="">
<meta name="csrf-token" content="{{ csrf_token() }}">
<!-- Styles -->
<link href="{{ asset(config('app.theme') . '/css/app.css') }}" rel="stylesheet">