Generate canonical and og:url from request path#1130
Conversation
There was a problem hiding this comment.
Pull request overview
Generates per-request canonical and og:url URLs in the shared layout instead of hardcoding the homepage, and enables X-Forwarded-Host so the host resolves correctly behind the reverse proxy.
Changes:
- Compute
canonicalUrlfromRequest.Scheme,Request.Host,PathBase, andPathin_Layout.cshtml. - Use
canonicalUrlfor both<meta property="og:url">and a new<link rel="canonical">. - Add
ForwardedHeaders.XForwardedHostto the forwarded headers configuration.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| EssentialCSharp.Web/Views/Shared/_Layout.cshtml | Builds a request-specific canonical URL and uses it for og:url and a new canonical link tag. |
| EssentialCSharp.Web/Program.cs | Adds XForwardedHost to the accepted forwarded headers so Request.Host reflects the original host behind the proxy. |
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Merge conflicts resolved in b18d7c0. The conflict in |
Why
The site metadata was inconsistent: og:url in _Layout.cshtml was hardcoded to the homepage, which did not match the actual route being viewed.
What changed
Notes for reviewers