fix: add CSRF token and cookies to deploy API requests

This commit is contained in:
F4ilji
2026-07-02 13:17:24 +05:00
parent 814c06bbb4
commit 92bb10faba
+20 -2
View File
@@ -15,9 +15,23 @@ const status = ref({
let pollingInterval = null
const getCsrfToken = () => {
const match = document.cookie.match(/XSRF-TOKEN=([^;]+)/)
return match ? decodeURIComponent(match[1]) : ''
}
const headers = {
'Content-Type': 'application/json',
'X-XSRF-TOKEN': getCsrfToken(),
'Accept': 'application/json',
}
const fetchStatus = async () => {
try {
const response = await fetch('/api/deploy/status')
const response = await fetch('/api/deploy/status', {
credentials: 'same-origin',
headers,
})
status.value = await response.json()
if (!status.value.running && pollingInterval) {
@@ -31,7 +45,11 @@ const fetchStatus = async () => {
const startDeploy = async () => {
try {
const response = await fetch('/api/deploy', { method: 'POST' })
const response = await fetch('/api/deploy', {
method: 'POST',
credentials: 'same-origin',
headers,
})
const data = await response.json()
if (response.ok) {