Use endpoint request over script workaround

This commit is contained in:
Korbs 2024-10-25 14:53:06 -04:00
parent f608045b47
commit 4a50e5df39

View file

@ -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)
}