mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-22 19:23:31 +00:00
fix: add CSRF token to export/import requests
- Export/import now includes X-CSRF-Token header from cookie - Fixes 403 Forbidden error when exporting with session auth - Both export and import endpoints now properly validate CSRF tokens
This commit is contained in:
@@ -561,10 +561,21 @@ const Settings: Component = () => {
|
||||
}
|
||||
|
||||
try {
|
||||
// Get CSRF token from cookie
|
||||
const csrfToken = document.cookie
|
||||
.split('; ')
|
||||
.find(row => row.startsWith('pulse_csrf='))
|
||||
?.split('=')[1];
|
||||
|
||||
const headers: HeadersInit = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
// Add CSRF token if available
|
||||
if (csrfToken) {
|
||||
headers['X-CSRF-Token'] = csrfToken;
|
||||
}
|
||||
|
||||
// Add API token if configured
|
||||
const apiToken = localStorage.getItem('apiToken');
|
||||
if (apiToken) {
|
||||
@@ -659,10 +670,21 @@ const Settings: Component = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get CSRF token from cookie
|
||||
const csrfToken = document.cookie
|
||||
.split('; ')
|
||||
.find(row => row.startsWith('pulse_csrf='))
|
||||
?.split('=')[1];
|
||||
|
||||
const headers: HeadersInit = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
// Add CSRF token if available
|
||||
if (csrfToken) {
|
||||
headers['X-CSRF-Token'] = csrfToken;
|
||||
}
|
||||
|
||||
// Add API token if configured
|
||||
const apiToken = localStorage.getItem('apiToken');
|
||||
if (apiToken) {
|
||||
|
||||
Reference in New Issue
Block a user