Skip to content

Commit

Permalink
fix(next-core): throw on invalid metadata handler
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Mar 4, 2024
1 parent b80d388 commit f86cd22
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ async fn dynamic_text_route_source(path: Vc<FileSystemPath>) -> Result<Vc<Box<dy

let content_type = get_content_type(path).await?;

// refer https://github.com/vercel/next.js/blob/7b2b9823432fb1fa28ae0ac3878801d638d93311/packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts#L84
// for the original template.
let code = formatdoc! {
r#"
import {{ NextResponse }} from 'next/server'
Expand All @@ -154,6 +156,10 @@ async fn dynamic_text_route_source(path: Vc<FileSystemPath>) -> Result<Vc<Box<dy
const cacheControl = {cache_control}
const fileType = {file_type}
if (typeof handler !== 'function') {{
throw new Error('Default export is missing in {resource_path}')
}}
export async function GET() {{
const data = await handler()
const content = resolveRouteData(data, fileType)
Expand Down

0 comments on commit f86cd22

Please sign in to comment.