fix: add credentials same-origin to Deploy fetch calls

Without this, session cookie is not sent with fetch() requests,
causing server to redirect to login (returning HTML instead of JSON).
This commit is contained in:
F4ilji
2026-07-02 01:29:05 +05:00
parent b42a733f53
commit de4fdc2c72
@@ -50,6 +50,7 @@ async function startDeploy() {
try { try {
const response = await fetch(route('dashboard.deploy'), { const response = await fetch(route('dashboard.deploy'), {
method: 'POST', method: 'POST',
credentials: 'same-origin',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'X-XSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '', 'X-XSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '',
@@ -79,12 +80,14 @@ function startPolling() {
pollInterval = setInterval(async () => { pollInterval = setInterval(async () => {
try { try {
const statusRes = await fetch(route('dashboard.deploy.status'), { const statusRes = await fetch(route('dashboard.deploy.status'), {
credentials: 'same-origin',
headers: { 'Accept': 'application/json' }, headers: { 'Accept': 'application/json' },
}) })
const statusData = await statusRes.json() const statusData = await statusRes.json()
deployStatus.value = statusData deployStatus.value = statusData
const logRes = await fetch(route('dashboard.deploy.log') + '?lines=100', { const logRes = await fetch(route('dashboard.deploy.log') + '?lines=100', {
credentials: 'same-origin',
headers: { 'Accept': 'application/json' }, headers: { 'Accept': 'application/json' },
}) })
const logData = await logRes.json() const logData = await logRes.json()
@@ -113,6 +116,7 @@ async function clearLog() {
try { try {
await fetch(route('dashboard.deploy.clear'), { await fetch(route('dashboard.deploy.clear'), {
method: 'POST', method: 'POST',
credentials: 'same-origin',
headers: { headers: {
'X-XSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '', 'X-XSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '',
'Accept': 'application/json', 'Accept': 'application/json',