@m13v/seo-components 0.41.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/seo-components",
3
- "version": "0.41.0",
3
+ "version": "0.41.1",
4
4
  "scripts": {
5
5
  "build:css": "tailwind -i src/_build.css -o dist/styles.css --minify",
6
6
  "lint:mobile-spans": "node scripts/lint-mobile-spans.mjs",
@@ -103,7 +103,24 @@ export function createDmShortLinkRedirectHandler(config: DmShortLinkRedirectConf
103
103
  ) {
104
104
  const { code: rawCode } = await ctx.params;
105
105
  const code = (rawCode || "").trim();
106
- const homeUrl = new URL("/", req.url).toString();
106
+ // Build the public home URL using forwarded headers. On Cloud Run the
107
+ // container is served at `0.0.0.0:8080` internally and Next.js sets
108
+ // `req.url` from that host, so `new URL("/", req.url)` would 302 users to
109
+ // `https://0.0.0.0:8080/` (unreachable). Vercel doesn't have this problem
110
+ // because its proxy rewrites `req.url` to the public host, but we share
111
+ // this handler across Vercel + Cloud Run consumers, so always prefer the
112
+ // forwarded host headers when present.
113
+ const fwdHost =
114
+ req.headers.get("x-forwarded-host") ||
115
+ req.headers.get("host") ||
116
+ "";
117
+ const fwdProto =
118
+ req.headers.get("x-forwarded-proto") ||
119
+ (fwdHost && !fwdHost.includes("localhost") ? "https" : "http");
120
+ const homeUrl =
121
+ fwdHost && !/(?:^|\.)0\.0\.0\.0(?::\d+)?$/.test(fwdHost)
122
+ ? `${fwdProto}://${fwdHost}/`
123
+ : new URL("/", req.url).toString();
107
124
 
108
125
  if (!/^[a-z0-9]{4,32}$/i.test(code)) {
109
126
  return Response.redirect(homeUrl, 302);