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

@ -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 =>
'<li><a href=/admin/texts/'
@ -18,6 +20,7 @@ document.addEventListener('DOMContentLoaded', () => {
const formData = new FormData(form);
const res = await fetch('/api/texts', {
method: 'POST',
credentials: 'same-origin',
body: formData,
});
if (res.ok) {