Use endpoint request over script workaround
This commit is contained in:
parent
f608045b47
commit
4a50e5df39
1 changed files with 15 additions and 0 deletions
15
source/src/pages/api/search/web.ts
Normal file
15
source/src/pages/api/search/web.ts
Normal 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)
|
||||||
|
}
|
Loading…
Reference in a new issue