mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 21:25:19 +02:00
feat: Enable credentials for GPX file fetch and add CORS_ALLOW_CREDENTIALS setting
This commit is contained in:
parent
e6e14e8d83
commit
5c74203103
3 changed files with 5 additions and 23 deletions
|
@ -295,6 +295,8 @@ CORS_ALLOWED_ORIGINS = [origin.strip() for origin in getenv('CSRF_TRUSTED_ORIGIN
|
||||||
|
|
||||||
CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in getenv('CSRF_TRUSTED_ORIGINS', 'http://localhost').split(',') if origin.strip()]
|
CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in getenv('CSRF_TRUSTED_ORIGINS', 'http://localhost').split(',') if origin.strip()]
|
||||||
|
|
||||||
|
CORS_ALLOW_CREDENTIALS = True
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
|
|
||||||
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
|
|
||||||
|
|
||||||
/** @type {import('./$types').RequestHandler} */
|
|
||||||
export async function GET(event) {
|
|
||||||
let sessionid = event.cookies.get('sessionid');
|
|
||||||
let fileName = event.params.file;
|
|
||||||
let res = await fetch(`${endpoint}/media/attachments/${fileName}`, {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Cookie: `sessionid=${sessionid}`
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let data = await res.text();
|
|
||||||
return new Response(data, {
|
|
||||||
status: res.status,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/xml'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -45,7 +45,9 @@
|
||||||
const promises = gpxfiles.map(async (gpxfile) => {
|
const promises = gpxfiles.map(async (gpxfile) => {
|
||||||
try {
|
try {
|
||||||
const gpxFileName = gpxfile.split('/').pop();
|
const gpxFileName = gpxfile.split('/').pop();
|
||||||
const res = await fetch('/gpx/' + gpxFileName);
|
const res = await fetch(gpxfile, {
|
||||||
|
credentials: 'include'
|
||||||
|
});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
console.error(`Failed to fetch GPX file: ${gpxFileName}`);
|
console.error(`Failed to fetch GPX file: ${gpxFileName}`);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue