Skip to content

fix(server): RSS SITE_ORIGIN + sitemap /page path - #112

Merged
one-ea merged 1 commit into
one-ea:mainfrom
Asakushen:fix/rss-site-origin-and-sitemap-page-path
Jul 23, 2026
Merged

fix(server): RSS SITE_ORIGIN + sitemap /page path#112
one-ea merged 1 commit into
one-ea:mainfrom
Asakushen:fix/rss-site-origin-and-sitemap-page-path

Conversation

@Asakushen

Copy link
Copy Markdown
Contributor

Summary

Two small SEO correctness fixes in server/src/index.ts. Verified still present on one-ea/Monolith@main before opening this PR.

1. RSS should prefer SITE_ORIGIN

Bug: /rss.xml builds channel/item links with new URL(c.req.url).origin only.

In the recommended Cloudflare setup, Pages Functions reverse-proxy /rss.xml to the Worker (client/functions/rss.xml.ts). The Worker then sees a *.workers.dev request origin, so the feed emits workers.dev absolute links instead of the public site domain.

Why this is real upstream: sitemap.xml and robots.txt already use c.env.SITE_ORIGIN || requestOrigin. RSS was left on request origin only. The env comment even documents SITE_ORIGIN for sitemap/robots, but not RSS.

Fix: use the same origin resolution as sitemap/robots:

const siteUrl = c.env.SITE_ORIGIN || new URL(c.req.url).origin;

2. Sitemap independent pages path is wrong

Bug: sitemap writes independent pages as /pages/:slug.

Frontend route is singular /page/:slug:

  • client/src/app.tsx<Route path="/page/:slug" ...>
  • navbar / footer / admin page preview all link to /page/${slug}

So sitemap currently advertises URLs that do not match the app router.

Fix: emit /page/:slug.

Test plan

  • With SITE_ORIGIN=https://example.com, GET /rss.xml channel/item <link> and <guid> use https://example.com, not the Worker host
  • Without SITE_ORIGIN, RSS still falls back to request origin (previous behavior)
  • GET /sitemap.xml independent page entries use /page/<slug> (not /pages/<slug>)
  • Existing post/archive/home sitemap entries unchanged
  • robots.txt behavior unchanged

Notes

  • Single-file change; no client/branding/local customizations included
  • Safe fallback retained when SITE_ORIGIN is unset

- RSS previously used request origin only. When /rss.xml is reverse-proxied
  through Pages Functions to the Worker, item/channel links become
  *.workers.dev instead of the public site origin. Prefer SITE_ORIGIN like
  sitemap.xml and robots.txt already do.
- Sitemap listed independent pages as /pages/:slug, but the SPA route is
  /page/:slug (client/src/app.tsx, navbar, footer, admin preview). Use the
  singular path so crawlers get valid URLs.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4847e82a-6d0c-4794-a799-b116c68f0f8f

📥 Commits

Reviewing files that changed from the base of the PR and between fb53892 and 88c6a21.

📒 Files selected for processing (1)
  • server/src/index.ts
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
server/src/index.ts

⚙️ CodeRabbit configuration file

server/src/index.ts: Hono Workers API 路由总入口。审查时请关注: 1. JWT 认证中间件是否正确保护管理接口 2. CORS 配置是否安全 3. 请求参数验证

Files:

  • server/src/index.ts
🔇 Additional comments (3)
server/src/index.ts (3)

30-30: LGTM!


608-610: LGTM!


681-684: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • 改进
    • 优化 RSS 链接生成:支持优先使用配置的站点公开域名,确保反向代理场景下链接一致。
    • 更新 Sitemap 中独立页面的链接路径,统一使用 /page/{slug} 格式。
    • 补充站点域名配置说明,明确其用于 Sitemap、Robots 和 RSS 地址生成。

Walkthrough

更新 SITE_ORIGIN 的用途说明,修正 RSS 在反代场景下的站点 URL 来源,并将 sitemap 独立页面路径同步为 /page/{slug}

Changes

站点 URL 生成

Layer / File(s) Summary
RSS 公开域名来源
server/src/index.ts
明确 SITE_ORIGIN 用于公开站点 URL;RSS 优先使用该值,否则回退到请求 origin。
Sitemap 独立页面路由
server/src/index.ts
独立页面 sitemap 条目从 /pages/{slug} 更新为 /page/{slug}

Estimated code review effort: 2 (Simple) | ~5 minutes

Possibly related PRs

Suggested labels: backend, bug

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题符合 Conventional Commits 格式,且准确概括了 RSS 的 SITE_ORIGIN 与 sitemap 路径修正。
Description check ✅ Passed 描述与本次 SEO URL 修复直接相关,清晰说明了 RSS 和 sitemap 的改动。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added backend 后端 (Hono Workers) 相关变更 bug Something isn't working labels Jul 13, 2026
@one-ea
one-ea merged commit 0b66221 into one-ea:main Jul 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 后端 (Hono Workers) 相关变更 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants