Skip to content

Commit

Permalink
fix: set x-nitro-prerender header as lower-case
Browse files Browse the repository at this point in the history
TODO: unenv should always do this with local fetch
  • Loading branch information
pi0 committed Aug 9, 2022
1 parent d6af502 commit 9cee698
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function prerender (nitro: Nitro) {
const _route: PrerenderGenerateRoute = { route }

// Fetch the route
const res = await (localFetch(withBase(route, nitro.options.baseURL), { headers: { 'X-Nitro-Prerender': route } }) as ReturnType<typeof fetch>)
const res = await (localFetch(withBase(route, nitro.options.baseURL), { headers: { 'x-nitro-prerender': route } }) as ReturnType<typeof fetch>)
_route.contents = await res.text()
if (res.status !== 200) {
_route.error = new Error(`[${res.status}] ${res.statusText}`) as any
Expand Down Expand Up @@ -118,7 +118,7 @@ function extractLinks (html: string, from: string, res: Response) {
// Extract from any <TAG href="">
_links.push(...Array.from(html.matchAll(LINK_REGEX)).map(m => m[1]))

// Extract from X-Nitro-Prerender headers
// Extract from x-nitro-prerender headers
const header = res.headers.get('x-nitro-prerender') || ''
_links.push(...header.split(',').map(i => i.trim()))

Expand Down
4 changes: 2 additions & 2 deletions test/fixture/routes/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default defineEventHandler((event) => {
'/api/param/foo.css'
]

appendHeader(event, 'X-Nitro-Prerender', '/api/param/prerender1, /api/param/prerender2')
appendHeader(event, 'X-Nitro-Prerender', '/api/param/prerender3')
appendHeader(event, 'x-nitro-prerender', '/api/param/prerender1, /api/param/prerender2')
appendHeader(event, 'x-nitro-prerender', '/api/param/prerender3')

return `
<ul>
Expand Down

0 comments on commit 9cee698

Please sign in to comment.