From 2f195e4fdf8f7fc077fa8eb50161d5e7a93f8937 Mon Sep 17 00:00:00 2001 From: Maik Kowol Date: Mon, 24 Jun 2024 05:08:15 +0200 Subject: [PATCH] fix: redirect using url config key (#256) --- src/runtime/nitro/middleware/redirect.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/nitro/middleware/redirect.ts b/src/runtime/nitro/middleware/redirect.ts index 89482a74..b1c70a32 100644 --- a/src/runtime/nitro/middleware/redirect.ts +++ b/src/runtime/nitro/middleware/redirect.ts @@ -4,12 +4,12 @@ import { useNitroOrigin, useSiteConfig } from '#imports' export default defineEventHandler((e) => { const siteConfig = useSiteConfig(e) - if (siteConfig.site) { - const siteConfigHostName = new URL(e.path, siteConfig.site).hostname + if (siteConfig.url) { + const siteConfigHostName = new URL(e.path, siteConfig.url).hostname const origin = useNitroOrigin(e) const originHostname = new URL(e.path, origin).hostname // if origin doesn't match site, do a redirect if (originHostname !== siteConfigHostName) - return sendRedirect(e, joinURL(siteConfig.site, e.path), 301) + return sendRedirect(e, joinURL(siteConfig.url, e.path), 301) } })