From 994969ba54abd50ecda9dff521116e62a4df3a7c Mon Sep 17 00:00:00 2001 From: Bad Manners Date: Fri, 30 Aug 2024 17:46:59 -0300 Subject: [PATCH] Fix redirects by checking redirect field instead --- src/htaccess.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/htaccess.ts b/src/htaccess.ts index 7ff547f..ef04fb6 100644 --- a/src/htaccess.ts +++ b/src/htaccess.ts @@ -113,11 +113,16 @@ export const integration = ({ generateHtaccessFile, errorPages, redirects, custo // Automatic error pages and Astro redirects () => (!error && - routes.reduce((acc, { type, route, redirectRoute }) => { + routes.reduce((acc, { type, route, redirect }) => { if (!error) { switch (type) { case "redirect": - acc.push(`RedirectMatch 301 ^${route}(/(index.html)?)?$ ${redirectRoute!.route}`); + const destination = typeof redirect === "string" ? redirect : redirect?.destination; + if (destination) { + acc.push(`RedirectMatch 301 ^${route}(/(index.html)?)?$ ${destination}`); + } else { + logger.warn(`No destination found for redirect route "${route}"! Skipping.`); + } break; case "page": if (errorPages === undefined) {