mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Add call to use X-CSRFToken in relevant POST methods
This commit is contained in:
parent
35e24d7851
commit
ddd550e6f4
4 changed files with 11 additions and 0 deletions
|
@ -98,8 +98,13 @@
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
configure.disabled = true;
|
configure.disabled = true;
|
||||||
configure.innerHTML = "Configuring...";
|
configure.innerHTML = "Configuring...";
|
||||||
|
const csrfToken = document.cookie.split('; ').find(row => row.startsWith('csrftoken'))?.split('=')[1];
|
||||||
fetch('/api/update?force=true&client=web', {
|
fetch('/api/update?force=true&client=web', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRFToken': csrfToken
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|
|
@ -79,10 +79,12 @@
|
||||||
var repo_name = document.getElementById("repo-name").value;
|
var repo_name = document.getElementById("repo-name").value;
|
||||||
var repo_branch = document.getElementById("repo-branch").value;
|
var repo_branch = document.getElementById("repo-branch").value;
|
||||||
|
|
||||||
|
const csrfToken = document.cookie.split('; ').find(row => row.startsWith('csrftoken'))?.split('=')[1];
|
||||||
fetch('/api/config/data/content_type/github', {
|
fetch('/api/config/data/content_type/github', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRFToken': csrfToken,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"pat_token": pat_token,
|
"pat_token": pat_token,
|
||||||
|
|
|
@ -131,10 +131,12 @@
|
||||||
var embeddings_file = document.getElementById("embeddings-file").value;
|
var embeddings_file = document.getElementById("embeddings-file").value;
|
||||||
var index_heading_entries = document.getElementById("index-heading-entries").value;
|
var index_heading_entries = document.getElementById("index-heading-entries").value;
|
||||||
|
|
||||||
|
const csrfToken = document.cookie.split('; ').find(row => row.startsWith('csrftoken'))?.split('=')[1];
|
||||||
fetch('/api/config/data/content_type/{{ content_type }}', {
|
fetch('/api/config/data/content_type/{{ content_type }}', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRFToken': csrfToken
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"input_files": input_files,
|
"input_files": input_files,
|
||||||
|
|
|
@ -61,10 +61,12 @@
|
||||||
var model = document.getElementById("model").value;
|
var model = document.getElementById("model").value;
|
||||||
var chat_model = document.getElementById("chat-model").value;
|
var chat_model = document.getElementById("chat-model").value;
|
||||||
|
|
||||||
|
const csrfToken = document.cookie.split('; ').find(row => row.startsWith('csrftoken'))?.split('=')[1];
|
||||||
fetch('/api/config/data/processor/conversation', {
|
fetch('/api/config/data/processor/conversation', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRFToken': csrfToken
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"openai_api_key": openai_api_key,
|
"openai_api_key": openai_api_key,
|
||||||
|
|
Loading…
Add table
Reference in a new issue