include credentials on fetch calls
This commit is contained in:
parent
4e039fb583
commit
c649dbbcc2
3 changed files with 11 additions and 4 deletions
|
|
@ -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 =>
|
||||
|
|
|
|||
|
|
@ -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 => {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue