fix: include Referer header in API requests
This commit is contained in:
@@ -37,7 +37,8 @@ export const actions: Actions = {
|
|||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': csrfToken,
|
'X-CSRFToken': csrfToken,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Cookie: `csrftoken=${csrfToken}`
|
Cookie: `csrftoken=${csrfToken}`,
|
||||||
|
Referer: event.url.origin // Include Referer header
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ export const actions: Actions = {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Cookie: `csrftoken=${csrfToken}; sessionid=${sessionId}`,
|
Cookie: `csrftoken=${csrfToken}; sessionid=${sessionId}`,
|
||||||
'X-CSRFToken': csrfToken
|
'X-CSRFToken': csrfToken,
|
||||||
|
Referer: event.url.origin // Include Referer header
|
||||||
},
|
},
|
||||||
body: formData
|
body: formData
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -66,7 +66,9 @@ export const actions: Actions = {
|
|||||||
let res = await fetch(`${serverEndpoint}/api/adventures/${event.params.id}`, {
|
let res = await fetch(`${serverEndpoint}/api/adventures/${event.params.id}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
Cookie: `sessionid=${event.cookies.get('sessionid')}; csrftoken=${csrfToken}`,
|
Referer: event.url.origin, // Include Referer header
|
||||||
|
Cookie: `sessionid=${event.cookies.get('sessionid')};
|
||||||
|
csrftoken=${csrfToken}`,
|
||||||
'X-CSRFToken': csrfToken
|
'X-CSRFToken': csrfToken
|
||||||
},
|
},
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ export const actions: Actions = {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': csrfToken,
|
'X-CSRFToken': csrfToken,
|
||||||
|
Referer: event.url.origin, // Include Referer header
|
||||||
Cookie: `sessionid=${sessionid}; csrftoken=${csrfToken}`
|
Cookie: `sessionid=${sessionid}; csrftoken=${csrfToken}`
|
||||||
},
|
},
|
||||||
body: formDataToSend
|
body: formDataToSend
|
||||||
@@ -174,9 +175,11 @@ export const actions: Actions = {
|
|||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': csrfToken,
|
'X-CSRFToken': csrfToken,
|
||||||
Cookie: `sessionid=${sessionId}; csrftoken=${csrfToken}`
|
Cookie: `sessionid=${sessionId}; csrftoken=${csrfToken}`,
|
||||||
|
Referer: event.url.origin // Include Referer header
|
||||||
},
|
},
|
||||||
body: formDataToSend,
|
body: formDataToSend,
|
||||||
|
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ export const actions: Actions = {
|
|||||||
headers: {
|
headers: {
|
||||||
Cookie: `sessionid=${sessionId}; csrftoken=${csrfToken}`,
|
Cookie: `sessionid=${sessionId}; csrftoken=${csrfToken}`,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-CSRFToken': csrfToken
|
'X-CSRFToken': csrfToken,
|
||||||
|
Referer: event.url.origin // Include Referer header
|
||||||
},
|
},
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ export const actions: Actions = {
|
|||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': csrfToken,
|
'X-CSRFToken': csrfToken,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Cookie: `csrftoken=${csrfToken}`
|
Cookie: `csrftoken=${csrfToken}`,
|
||||||
|
Referer: event.url.origin // Include Referer header
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ username, password }),
|
body: JSON.stringify({ username, password }),
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
@@ -73,7 +74,8 @@ export const actions: Actions = {
|
|||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': csrfToken,
|
'X-CSRFToken': csrfToken,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Cookie: `csrftoken=${csrfToken}; sessionid=${sessionId}`
|
Cookie: `csrftoken=${csrfToken}; sessionid=${sessionId}`,
|
||||||
|
Referer: event.url.origin // Include Referer header
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ code: totp }),
|
body: JSON.stringify({ code: totp }),
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ export const actions: Actions = {
|
|||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': csrfToken,
|
'X-CSRFToken': csrfToken,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Cookie: `csrftoken=${csrfToken}`
|
Cookie: `csrftoken=${csrfToken}`,
|
||||||
|
Referer: event.url.origin // Include Referer header
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
username: username,
|
username: username,
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ export const actions: Actions = {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-CSRFToken': csrfToken,
|
'X-CSRFToken': csrfToken,
|
||||||
Cookie: `csrftoken=${csrfToken}`
|
Cookie: `csrftoken=${csrfToken}`,
|
||||||
|
Referer: event.url.origin // Include Referer header
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
email
|
email
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ export const actions: Actions = {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Cookie: `csrftoken=${csrfToken}`,
|
Cookie: `csrftoken=${csrfToken}`,
|
||||||
'X-CSRFToken': csrfToken
|
'X-CSRFToken': csrfToken,
|
||||||
|
Referer: event.url.origin // Include Referer header
|
||||||
},
|
},
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
|
|||||||
Reference in New Issue
Block a user