diff --git a/public/js/home.js b/public/js/home.js index c943cd4..e7abc7c 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -3,7 +3,9 @@ document.addEventListener('DOMContentLoaded', () => { const createPlanModal = document.getElementById('create-plan-modal'); async function loadTexts() { - const response = await fetch('/api/texts'); + const response = await fetch('/api/texts', { + credentials: 'same-origin', + }); const texts = await response.json(); textsList.innerHTML = texts .map(text => diff --git a/public/js/text.js b/public/js/text.js index 0388bf6..59fc4ee 100644 --- a/public/js/text.js +++ b/public/js/text.js @@ -1,7 +1,7 @@ document.addEventListener('DOMContentLoaded', () => { const textId = window.location.pathname.split('/').pop(); - fetch('/api/texts/' + textId) + fetch('/api/texts/' + textId, { credentials: 'same-origin' }) .then(res => res.json()) .then(text => { const h1 = document.createElement('h1'); @@ -13,7 +13,7 @@ document.addEventListener('DOMContentLoaded', () => { }); function fetchAndRenderNodes(textId) { - return fetch('/api/nodes/' + textId) + return fetch('/api/nodes/' + textId, { credentials: 'same-origin' }) .then(res => res.json()) .then(nodes => { const existing = document.querySelector('#text-detail > ul'); @@ -113,6 +113,7 @@ function toggleAddForm(li, parentNodeId, textId) { fetch('/api/nodes', { method: 'POST', headers: { 'Content-Type': 'application/json' }, + credentials: 'same-origin', body: JSON.stringify({ textId: parseInt(textId), title, parentNodeId }), }) .then(res => { @@ -157,6 +158,7 @@ function toggleBulkAddForm(li, parentNodeId, textId) { fetch('/api/nodes/bulk', { method: 'POST', headers: { 'Content-Type': 'application/json' }, + credentials: 'same-origin', body: JSON.stringify({ textId: parseInt(textId), parentNodeId, titlePrefix, count }), }) .then(res => { diff --git a/public/js/texts.js b/public/js/texts.js index 1937749..029196d 100644 --- a/public/js/texts.js +++ b/public/js/texts.js @@ -3,7 +3,9 @@ document.addEventListener('DOMContentLoaded', () => { const form = document.getElementById('texts-form'); async function loadTexts() { - const res = await fetch('/api/texts'); + const res = await fetch('/api/texts', { + credentials: 'same-origin', + }); const texts = await res.json(); textsList.innerHTML = texts.map(text => '