rsnext/test/e2e/app-dir/metadata-dynamic-routes/app/layout.tsx
Jiachi Liu 6dbb6318a1
Provide default metadataBase for local and vercel deployment (#47568)
### What?

- Provide a default `metadataBase` 
- Always resolve urls that could be resolved as absolute with
`metadataBase`, e.g. tw/og urls, canonical urls
- Give a warning in dev mode if user doesn't provide one in dev
- Error if you don't have it but it's required in production

On production it will leverage `VERCEL_URL` if users expose it to the
deployment

### Why?

OG image urls are required to be absolute urls instead of relative urls.
For metadata image conventions we let users don't have to provide
`metadataBase` explicitly when they expect it should be the origin of
their next app.

### How?

Closes NEXT-887

---------
2023-03-30 16:27:24 -07:00

21 lines
526 B
TypeScript

export default function Layout({ children }) {
return (
<html>
<head></head>
<body>{children}</body>
</html>
)
}
export const metadata = {
metadataBase: process.env.VERCEL_URL
? new URL(`https://${process.env.VERCEL_URL}`)
: new URL(`http://localhost:${process.env.PORT || 3000}`),
title: 'Next.js App',
description: 'This is a Next.js App',
twitter: {
cardType: 'summary_large_image',
title: 'Twitter - Next.js App',
description: 'Twitter - This is a Next.js App',
},
}