d3fb510bbb
This commit adds a new '/api/instances' endpoint that returns the domains of the available Mastodon instances. This also changes the input field, making it accept a host rather than the full domain.
16 lines
471 B
TypeScript
16 lines
471 B
TypeScript
import { APIRoute } from "astro";
|
|
|
|
export const post: APIRoute = async ({ redirect, request }) => {
|
|
const formData = await request.formData();
|
|
|
|
const text = (formData.get("text") as string) || "";
|
|
const instanceDomain =
|
|
(formData.get("instance") as string) || "mastodon.social";
|
|
|
|
const publishUrl = new URL("/share", `https://${instanceDomain}/`);
|
|
publishUrl.search = new URLSearchParams({
|
|
text,
|
|
}).toString();
|
|
|
|
return redirect(publishUrl.toString(), 303);
|
|
};
|