include credentials on fetch calls

This commit is contained in:
Yisroel Baum 2026-04-24 13:30:54 +03:00
parent 4e039fb583
commit c649dbbcc2
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
3 changed files with 11 additions and 4 deletions

View file

@ -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 => {