fix login & add sveltestrap

This commit is contained in:
ThePetrovich 2025-06-26 19:15:33 +08:00
parent a822fb1e36
commit 527d4417ff
15 changed files with 373 additions and 191 deletions

View file

@ -2,6 +2,9 @@ import { writable } from "svelte/store"
import type { LatLngExpression } from "leaflet";
import L from "leaflet";
import { getCsrfToken } from "./auth";
interface TrajectoryPoint {
altitude: number;
datetime: string;
@ -104,12 +107,19 @@ export const getForecast = async (flightParameters: Record<string, any>, startDa
try {
// Example POST request - replace with your actual API endpoint
const response = await fetch('http://127.0.0.1:8000/api/predictions', {
const csrfToken = await getCsrfToken();
if (!csrfToken) {
throw new Error('CSRF token not found');
}
const response = await fetch('http://localhost:8000/api/predictions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
},
body: JSON.stringify(flightParameters)
body: JSON.stringify(flightParameters),
credentials: 'include'
});
if (!response.ok) {