robots.txt and sitemap.xml missing – T#444
Conversation
…dd robots.txt & sitemap Pi-Defi-world#323: Replace shared step state with per-tab tabSteps record so switching tabs no longer resets other tabs' form input. Switch Tabs from uncontrolled (defaultValue) to controlled (value). resetForm now only clears the active tab's fields. Also fixed pre-existing bugs in the same file: - Duplicate useBalance() call - setSubmitError -> setApiError - Missing QuoteResponse import - metadata export in a use client file Pi-Defi-world#359: Add app/robots.ts and app/sitemap.ts via Next.js Metadata Route API. robots.ts disallows all authenticated routes; sitemap.ts lists only the 4 public pages (/, /auth/signin, /auth/signup, /recovery). Both respect NEXT_PUBLIC_SITE_URL env var.
…bots-sitemap fix(Pi-Defi-world#323,Pi-Defi-world#359): preserve currency tab form state + add robots.txt & sitemap
|
@Gadflyxx Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
📝 WalkthroughWalkthroughThe PR adds Next.js SEO metadata routes (robots.ts and sitemap.ts) and refactors form state management in the currency page to preserve per-tab input. The confirmation step is moved from a global state into a per-tab map keyed by activeTab, and form reset now clears only the current tab's fields. ChangesSEO Metadata Routes
Currency Page Tab-Specific Form State
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/sitemap.ts (1)
4-10: ⚡ Quick winExtract shared site-origin helper to avoid drift between sitemap and robots.
app/sitemap.tsandapp/robots.tsduplicate base URL derivation. Centralizing this keeps both routes consistent and avoids future SEO mismatches.Suggested refactor
+// lib/site-origin.ts +export function getSiteOrigin(): string { + const raw = process.env.NEXT_PUBLIC_SITE_URL ?? "https://app.acbu.io"; + return new URL(raw).origin; +}// app/sitemap.ts import type { MetadataRoute } from "next"; +import { getSiteOrigin } from "`@/lib/site-origin`"; export default function sitemap(): MetadataRoute.Sitemap { - const base = process.env.NEXT_PUBLIC_SITE_URL ?? "https://app.acbu.io"; + const base = getSiteOrigin(); return [// app/robots.ts import type { MetadataRoute } from "next"; +import { getSiteOrigin } from "`@/lib/site-origin`"; export default function robots(): MetadataRoute.Robots { - const rawBase = process.env.NEXT_PUBLIC_SITE_URL ?? "https://app.acbu.io"; - const base = new URL(rawBase).origin; + const base = getSiteOrigin(); return {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/sitemap.ts` around lines 4 - 10, Extract the base URL derivation into a shared helper (e.g., getSiteOrigin) so both sitemap.ts and robots.ts import the same logic; move the code that computes const base = process.env.NEXT_PUBLIC_SITE_URL ?? "https://app.acbu.io" into that helper, export the function, and replace the inline base usages in sitemap.ts (the array entries using `${base}`) and robots.ts to call getSiteOrigin() instead, preserving the same env var name and fallback value to avoid any URL drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/robots.ts`:
- Around line 4-33: Normalize the NEXT_PUBLIC_SITE_URL before composing
metadata: compute a normalizedBase from process.env.NEXT_PUBLIC_SITE_URL
(fallback "https://app.acbu.io") by ensuring it includes a scheme (prepend
"https://" if missing) and stripping any trailing slashes (e.g., replace /\/+$/
with empty string), then use that normalizedBase instead of base when setting
sitemap (`sitemap: `${normalizedBase}/sitemap.xml``) and anywhere else `base` is
used so you never produce double slashes or malformed URLs.
---
Nitpick comments:
In `@app/sitemap.ts`:
- Around line 4-10: Extract the base URL derivation into a shared helper (e.g.,
getSiteOrigin) so both sitemap.ts and robots.ts import the same logic; move the
code that computes const base = process.env.NEXT_PUBLIC_SITE_URL ??
"https://app.acbu.io" into that helper, export the function, and replace the
inline base usages in sitemap.ts (the array entries using `${base}`) and
robots.ts to call getSiteOrigin() instead, preserving the same env var name and
fallback value to avoid any URL drift.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e871bf2e-b47a-42de-9922-bd437d977325
📒 Files selected for processing (3)
app/currency/page.tsxapp/robots.tsapp/sitemap.ts
| const base = process.env.NEXT_PUBLIC_SITE_URL ?? "https://app.acbu.io"; | ||
| return { | ||
| rules: [ | ||
| { | ||
| userAgent: "*", | ||
| allow: ["/", "/auth/signin", "/auth/signup", "/recovery"], | ||
| disallow: [ | ||
| "/auth/2fa", | ||
| "/auth/wallet-setup", | ||
| "/me/", | ||
| "/wallet/", | ||
| "/send/", | ||
| "/currency/", | ||
| "/mint/", | ||
| "/burn/", | ||
| "/savings/", | ||
| "/lending/", | ||
| "/transactions/", | ||
| "/activity/", | ||
| "/bills/", | ||
| "/fiat/", | ||
| "/rates/", | ||
| "/reserves/", | ||
| "/business/", | ||
| "/api/", | ||
| ], | ||
| }, | ||
| ], | ||
| sitemap: `${base}/sitemap.xml`, | ||
| }; |
There was a problem hiding this comment.
Normalize NEXT_PUBLIC_SITE_URL before composing metadata URLs.
On Line 4 and Line 32, raw env concatenation can produce invalid URLs (e.g., double slashes or unexpected path prefixes), which can degrade crawler behavior.
Suggested fix
import type { MetadataRoute } from "next";
export default function robots(): MetadataRoute.Robots {
- const base = process.env.NEXT_PUBLIC_SITE_URL ?? "https://app.acbu.io";
+ const rawBase = process.env.NEXT_PUBLIC_SITE_URL ?? "https://app.acbu.io";
+ const base = new URL(rawBase).origin;
return {
rules: [
{
userAgent: "*",
allow: ["/", "/auth/signin", "/auth/signup", "/recovery"],
@@
],
sitemap: `${base}/sitemap.xml`,
};
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const base = process.env.NEXT_PUBLIC_SITE_URL ?? "https://app.acbu.io"; | |
| return { | |
| rules: [ | |
| { | |
| userAgent: "*", | |
| allow: ["/", "/auth/signin", "/auth/signup", "/recovery"], | |
| disallow: [ | |
| "/auth/2fa", | |
| "/auth/wallet-setup", | |
| "/me/", | |
| "/wallet/", | |
| "/send/", | |
| "/currency/", | |
| "/mint/", | |
| "/burn/", | |
| "/savings/", | |
| "/lending/", | |
| "/transactions/", | |
| "/activity/", | |
| "/bills/", | |
| "/fiat/", | |
| "/rates/", | |
| "/reserves/", | |
| "/business/", | |
| "/api/", | |
| ], | |
| }, | |
| ], | |
| sitemap: `${base}/sitemap.xml`, | |
| }; | |
| const rawBase = process.env.NEXT_PUBLIC_SITE_URL ?? "https://app.acbu.io"; | |
| const base = new URL(rawBase).origin; | |
| return { | |
| rules: [ | |
| { | |
| userAgent: "*", | |
| allow: ["/", "/auth/signin", "/auth/signup", "/recovery"], | |
| disallow: [ | |
| "/auth/2fa", | |
| "/auth/wallet-setup", | |
| "/me/", | |
| "/wallet/", | |
| "/send/", | |
| "/currency/", | |
| "/mint/", | |
| "/burn/", | |
| "/savings/", | |
| "/lending/", | |
| "/transactions/", | |
| "/activity/", | |
| "/bills/", | |
| "/fiat/", | |
| "/rates/", | |
| "/reserves/", | |
| "/business/", | |
| "/api/", | |
| ], | |
| }, | |
| ], | |
| sitemap: `${base}/sitemap.xml`, | |
| }; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@app/robots.ts` around lines 4 - 33, Normalize the NEXT_PUBLIC_SITE_URL before
composing metadata: compute a normalizedBase from
process.env.NEXT_PUBLIC_SITE_URL (fallback "https://app.acbu.io") by ensuring it
includes a scheme (prepend "https://" if missing) and stripping any trailing
slashes (e.g., replace /\/+$/ with empty string), then use that normalizedBase
instead of base when setting sitemap (`sitemap:
`${normalizedBase}/sitemap.xml``) and anywhere else `base` is used so you never
produce double slashes or malformed URLs.
Summary
Fixes two issues: #323 and #359.
#323 — Form reset on tab switch in /currency
Root cause:
stepwas a single shared state across all three tabs. Switching tabs carried the step into the new tab, and<Tabs>useddefaultValue(uncontrolled) soactiveTabstate could drift from the rendered tab.Fix:
const [step, setStep]withconst [tabSteps, setTabSteps]— aRecord<tab, TabStep>giving each tab its own independent stepstep/setStepfromtabSteps[activeTab]— all existing call sites unchanged<Tabs defaultValue="mint">→<Tabs value={activeTab}>(controlled)resetFormnow only clears the active tab's fields, not all threeAlso fixed pre-existing bugs in the same file:
useBalance()call (would throw a React hook error)setSubmitErrorcalled but never defined →setApiErrorQuoteResponseused in state but not importedexport const metadatain a"use client"file (silently ignored by Next.js — removed)closes Form reset on tab switch in /currency – M #323
#359 — robots.txt and sitemap.xml missing
Added
app/robots.tsandapp/sitemap.tsusing Next.js's built-in Metadata Route API (generates/robots.txtand/sitemap.xmlat build time — no static files needed)./me/,/wallet/,/currency/,/transactions/, etc.), allows only public pages/,/auth/signin,/auth/signup,/recoveryNEXT_PUBLIC_SITE_URLenv var with fallback tohttps://app.acbu.ioFiles changed
app/currency/page.tsx— tab state fix + pre-existing bug fixesapp/robots.ts— newapp/sitemap.ts— newcloses robots.txt and sitemap.xml missing – T #359
Summary by CodeRabbit
New Features
Refactor