Open md-coops opened 1 year ago
I'm having exactly the same issue with the latest version at the time of writing (NextJS 14.x). Both warnings from NextJS and what the documentation says about this property are pretty confusing by the way.
Who's lying? Is it the docs which say you can use it in all fields (when in fact it doesn't work)? Or only for OpenGraph links?
It is kind of a bummer to be forced to define metadataBase
with an absolute URL for the root layout. The reason why is unclear to me.
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Metadata (metadata, generateMetadata, next/head), Static HTML Export (output: "export")
Link to the code that reproduces this issue or a replay of the bug
https://github.com/md-coops/nextJS-bug-report
To Reproduce
Run
npm run build
to build static export solution.Describe the Bug
In the ./src/app/layout.tsx file, setting
metadata.metadataBase = "https://custom.domain"
does not append the base url tohref
attributes for link tags in the head tag of html pages. We can see this when generating a static export and inspecting the generated./out/index.html
.Expected Behavior
I would expect the key of
metadata.metadataBase
to pre-pend the relative URLs in thehref
atribute in link tags in the head tag of html documents. e.g.<head><link rel="stylesheet" href="https://custom.domain/_next/static/css/25ef7fcca74b1a97.css" data-precedence="next"/></ head>
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response