Skip to content

Commit 4eb8f59

Browse files
committedAug 30, 2023
fix: show log upon permanent redirect defined by config.redirects
1 parent 5c416b3 commit 4eb8f59

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎vite-plugin-ssr/node/runtime/renderPage.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ async function renderPageAndPrepare(
149149
}
150150

151151
{
152-
const pageContextHttpReponse = getPermanentRedirect(pageContextInit)
152+
const pageContextHttpReponse = getPermanentRedirect(pageContextInit, httpRequestId)
153153
if (pageContextHttpReponse) return pageContextHttpReponse
154154
}
155155

@@ -467,7 +467,7 @@ function normalizePathname(pageContextInit: { urlOriginal: string }) {
467467
return pageContextHttpResponse
468468
}
469469

470-
function getPermanentRedirect(pageContextInit: { urlOriginal: string }) {
470+
function getPermanentRedirect(pageContextInit: { urlOriginal: string }, httpRequestId: number) {
471471
const { redirects, baseServer } = getGlobalContext()
472472
const urlWithoutBase = removeBaseServer(pageContextInit.urlOriginal, baseServer)
473473
let urlPathname: undefined | string
@@ -477,6 +477,11 @@ function getPermanentRedirect(pageContextInit: { urlOriginal: string }) {
477477
})
478478
assert(urlPathname)
479479
if (urlRedirect === urlWithoutBase) return null
480+
logRuntimeInfo?.(
481+
`Permanent redirect defined by your config.redirects (https://vite-plugin-ssr.com/redirects)`,
482+
httpRequestId,
483+
'info'
484+
)
480485
urlRedirect = prependBase(urlRedirect, baseServer)
481486
assert(urlRedirect !== pageContextInit.urlOriginal)
482487
const httpResponse = createHttpResponseObjectRedirect({ url: urlRedirect, statusCode: 301 }, urlPathname)

0 commit comments

Comments
 (0)
Please sign in to comment.