React Router page actions wrap responses, preventing raw file downloads. Moved GPX export to GET /api/routes/:id/gpx and changed the button to a plain <a download> link. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
16 lines
529 B
TypeScript
16 lines
529 B
TypeScript
import type { Route } from "./+types/api.routes.$id.gpx";
|
|
import { getRouteWithVersions } from "~/lib/routes.server";
|
|
|
|
export async function loader({ params }: Route.LoaderArgs) {
|
|
const route = await getRouteWithVersions(params.id);
|
|
if (!route?.gpx) {
|
|
return new Response("No GPX data", { status: 404 });
|
|
}
|
|
|
|
return new Response(route.gpx, {
|
|
headers: {
|
|
"Content-Type": "application/gpx+xml",
|
|
"Content-Disposition": `attachment; filename="${route.name.replace(/[^a-z0-9]/gi, "_")}.gpx"`,
|
|
},
|
|
});
|
|
}
|