resolve csrf
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
{% extends "appbuilder/base.html" %}
|
{% extends "appbuilder/base.html" %}
|
||||||
|
|
||||||
|
{% block head_meta %}
|
||||||
|
{{ super() }}
|
||||||
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<!-- Banner -->
|
<!-- Banner -->
|
||||||
@@ -237,8 +242,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const provider = selectedModel.getAttribute('data-provider');
|
const [provider, modelId] = selectedModel.value.split(':');
|
||||||
const modelId = selectedModel.value.split(':')[1];
|
|
||||||
const modelName = provider === 'openrouter' ? modelNameInput.value : modelId;
|
const modelName = provider === 'openrouter' ? modelNameInput.value : modelId;
|
||||||
|
|
||||||
// Clear input and add user message
|
// Clear input and add user message
|
||||||
@@ -268,11 +272,29 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug log the request
|
||||||
|
const requestData = {
|
||||||
|
provider: provider,
|
||||||
|
model: modelName,
|
||||||
|
messages: messages,
|
||||||
|
api_key: apiKey,
|
||||||
|
stream: true,
|
||||||
|
temperature: 0.7
|
||||||
|
};
|
||||||
|
console.log('Sending request:', {...requestData, api_key: '***'});
|
||||||
|
|
||||||
|
// Get CSRF token
|
||||||
|
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
||||||
|
if (!csrfToken) {
|
||||||
|
throw new Error('CSRF token not found. Please refresh the page.');
|
||||||
|
}
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
const response = await fetch('/wingman/chat', {
|
const response = await fetch('/wingman/chat', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRFToken': csrfToken
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
provider: provider,
|
provider: provider,
|
||||||
|
|||||||
Reference in New Issue
Block a user