Skip to content

refactor(dashboard): centralize app URL usage and enhance robots.txt …#369

Merged
izadoesdev merged 1 commit intodatabuddy-analytics:mainfrom
mezotv:feat/status-seo-v2
Mar 29, 2026
Merged

refactor(dashboard): centralize app URL usage and enhance robots.txt …#369
izadoesdev merged 1 commit intodatabuddy-analytics:mainfrom
mezotv:feat/status-seo-v2

Conversation

@mezotv
Copy link
Copy Markdown
Contributor

@mezotv mezotv commented Mar 29, 2026

  • Replaced hardcoded URLs with APP_URL constant for consistency across layout, OG image generation, and status pages.
  • Updated robots.txt to allow access to the /public/ path in addition to /status/.
Checklist
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

…rules

- Replaced hardcoded URLs with APP_URL constant for consistency across layout, OG image generation, and status pages.
- Updated robots.txt to allow access to the /public/ path in addition to /status/.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 29, 2026

@mezotv is attempting to deploy a commit to the Databuddy OSS Team on Vercel.

A member of the Team first needs to authorize it.

@vercel vercel Bot temporarily deployed to Preview – databuddy-links March 29, 2026 23:16 Inactive
@vercel vercel Bot temporarily deployed to Preview – documentation March 29, 2026 23:16 Inactive
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 29, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e2a275f1-1db1-463a-af4e-891a860a9539

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
databuddy-links Skipped Skipped Mar 29, 2026 11:16pm
documentation Skipped Skipped Mar 29, 2026 11:16pm

@izadoesdev izadoesdev merged commit e3b4ec7 into databuddy-analytics:main Mar 29, 2026
12 of 13 checks passed
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 29, 2026

Greptile Summary

This PR centralizes the hardcoded https://app.databuddy.cc URL into a single APP_URL constant (sourced from NEXT_PUBLIC_APP_URL with a fallback), applies it consistently across layout metadata, OG image generation, the status navbar, and status page metadata, and also introduces a new sitemap for public status pages. The changes are well-scoped and low-risk overall.

Key changes:

  • New apps/dashboard/lib/app-url.ts module exporting APP_URL and a getStatusPageUrl helper, replacing six separate hardcoded URL strings across the codebase.
  • New apps/dashboard/app/sitemap.ts that queries the DB for public, active status pages and generates a daily-revalidated sitemap — a useful SEO addition.
  • robots.ts updated to allow /public/ alongside /status/ and gains a proper newline at EOF.
  • status/[slug]/page.tsx gains an alternates.canonical tag, but uses a root-relative path (/status/${slug}) while the sibling openGraph.url in the same block uses the absolute URL from getStatusPageUrl — minor inconsistency worth aligning.
  • APP_URL does not strip a potential trailing slash from NEXT_PUBLIC_APP_URL, which could produce double-slash URLs if the env var is misconfigured.

Confidence Score: 5/5

Safe to merge — all findings are minor style and defensive-coding suggestions with no current breakage.

All three comments are P2: the trailing-slash guard is a defensive best practice (not a current bug given the fallback default has no slash), the sitemap helper inconsistency is purely stylistic, and the canonical/openGraph URL format mismatch is functionally equivalent due to Next.js metadataBase resolution. No logic errors, security issues, or broken contracts were found.

Minor improvements suggested for apps/dashboard/lib/app-url.ts, apps/dashboard/app/sitemap.ts, and apps/dashboard/app/status/[slug]/page.tsx.

Important Files Changed

Filename Overview
apps/dashboard/lib/app-url.ts New module centralizing APP_URL and getStatusPageUrl helper; trailing slash not stripped from env var which can produce double-slash URLs.
apps/dashboard/app/sitemap.ts New sitemap for public status pages with proper caching; manually constructs status URLs instead of using getStatusPageUrl helper.
apps/dashboard/app/status/[slug]/page.tsx Replaces hardcoded URLs with getStatusPageUrl; new alternates.canonical uses a relative path inconsistently with the absolute openGraph.url in the same block.
apps/dashboard/app/layout.tsx Replaces three hardcoded https://app.databuddy.cc URLs with APP_URL constant; clean change.
apps/dashboard/app/robots.ts Adds /public/ to allowed crawl paths alongside /status/; also fixes missing newline at end of file.
apps/dashboard/app/status/[slug]/_components/status-navbar.tsx Replaces hardcoded login URL with APP_URL constant; straightforward clean-up.
apps/dashboard/app/(dby)/dby/l/[slug]/page.tsx Replaces hardcoded OG image base URL with APP_URL constant; clean change.
apps/dashboard/types/sitemap.ts New type definition file for StatusSitemapRow; minimal and correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    ENV["NEXT_PUBLIC_APP_URL env var\n(fallback: https://app.databuddy.cc)"]
    APPURL["lib/app-url.ts\nAPP_URL constant\ngetStatusPageUrl(slug)"]
    ENV --> APPURL

    APPURL --> LAYOUT["app/layout.tsx\nmetadataBase, openGraph.url,\nalternates.canonical"]
    APPURL --> OGPAGE["(dby)/dby/l/[slug]/page.tsx\nOG_IMAGE_BASE"]
    APPURL --> NAVBAR["status/[slug]/_components/status-navbar.tsx\nLogin href"]
    APPURL --> SITEMAP["app/sitemap.ts\nstatus page URLs"]
    APPURL --> STATUSPAGE["status/[slug]/page.tsx\nopenGraph.url, JSON-LD url"]

    ROBOTS["app/robots.ts\nallow: /status/, /public/"]
Loading

Reviews (1): Last reviewed commit: "refactor(dashboard): centralize app URL ..." | Re-trigger Greptile

const statusPages = await getPublicStatusPages();

return statusPages.map((statusPage) => ({
url: `${APP_URL}/status/${statusPage.slug}`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 getStatusPageUrl helper not reused

The getStatusPageUrl helper was introduced in lib/app-url.ts specifically to build status page URLs, and it's correctly used in status/[slug]/page.tsx. However, the sitemap constructs the same URL manually instead of calling the helper, creating a subtle inconsistency.

Suggested change
url: `${APP_URL}/status/${statusPage.slug}`,
url: getStatusPageUrl(statusPage.slug),

You'll also need to add the import at the top of the file:

import { APP_URL, getStatusPageUrl } from "@/lib/app-url";

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +1 to +2
export const APP_URL =
process.env.NEXT_PUBLIC_APP_URL || "https://app.databuddy.cc";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Trailing slash on NEXT_PUBLIC_APP_URL not stripped

If NEXT_PUBLIC_APP_URL is set with a trailing slash (e.g. https://app.databuddy.cc/), every constructed URL will contain a double slash (e.g. https://app.databuddy.cc//status/my-org). It's a good defensive practice to strip a trailing slash here so downstream usages remain correct regardless of how the env var is configured.

Suggested change
export const APP_URL =
process.env.NEXT_PUBLIC_APP_URL || "https://app.databuddy.cc";
export const APP_URL = (
process.env.NEXT_PUBLIC_APP_URL || "https://app.databuddy.cc"
).replace(/\/$/, "");

Comment on lines +66 to +68
alternates: {
canonical: `/status/${slug}`,
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Canonical is relative while openGraph.url is absolute

Within the same metadata block, alternates.canonical uses a root-relative path (/status/${slug}) while openGraph.url (line 72) uses the fully-qualified URL from getStatusPageUrl. Both resolve to the same address because metadataBase is set in layout.tsx, but the inconsistency can be confusing and could cause issues if metadataBase is ever changed or unset.

Aligning them to both use getStatusPageUrl(slug) would make the intent clearer:

Suggested change
alternates: {
canonical: `/status/${slug}`,
},
alternates: {
canonical: getStatusPageUrl(slug),
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants