diff --git a/source/src/pages/api/search/web.ts b/source/src/pages/api/search/web.ts new file mode 100644 index 0000000..0782919 --- /dev/null +++ b/source/src/pages/api/search/web.ts @@ -0,0 +1,15 @@ +import type { APIRoute } from "astro" + +export const POST: APIRoute = async ({ request, redirect }) => { + // Get Form Data + const formData = await request.formData() + const web_search = formData.get("websearch")?.toString() + + // If the user presses "Enter" on a blank search, return to home + if (!web_search) { + return redirect("/") + } + + // Go to search term + return redirect("/web?=" + web_search) +} \ No newline at end of file