Skip to content

fix: disable expo router sitemap in production builds - #164

Merged
fernandatoledo merged 10 commits into
masterfrom
fix/disable-sitemap-in-production
Nov 16, 2026
Merged

fernandatoledo merged 10 commits into
masterfrom
fix/disable-sitemap-in-production

Conversation

@devs-rootstrap

Copy link
Copy Markdown
Collaborator

Jira board reference:


What does this do?

  • Configures the expo-router plugin in app.config.ts with sitemap: Env.APP_ENV !== 'production', so the auto-generated /_sitemap route is no longer included in production builds. Development, QA and staging builds keep it.
  • Adds __tests__/app-config.test.ts, which loads app.config.ts for each APP_ENV and asserts the expo-router plugin options (sitemap: false for production, true for the rest).
  • Documents the behavior in the Expo Router guide (docs/src/content/docs/guides/navigation.mdx), including how to change it.

Why did you do this?

Expo Router injects a /_sitemap route listing every route in the app. The Expo docs don't say whether it is excluded from release builds, so I checked the source: in expo-router 6.0.23 (the version we use), getRoutesCore.js adds the sitemap route whenever options.sitemap !== false, with no check for dev vs. release. The option comes from the config plugin's sitemap setting, which is written to extra.router and read at runtime. So today the route ships in production builds and exposes the full route list.

It's still a useful debugging aid, so it stays enabled in every non-production environment.

Assumptions:

  • Only production should drop the sitemap; development, qa and staging keep it.
  • Gating on Env.APP_ENV follows the same pattern already used for the app icon badge in app.config.ts.

Who/what does this impact?

  • Production builds: <scheme>://_sitemap (and /_sitemap on web) now lands on the not-found screen instead of the route list.
  • Non-production builds: no change.
  • Projects created from the template inherit this default and can flip it in app.config.ts.

Layer 2: Risk Classification

Author applies a risk label when opening the PR. When in doubt, escalate.

Label When to use
risk:low Config, copy, minor UI tweaks. Low blast radius.
risk:medium Feature work, refactors touching multiple files.
risk:high Auth, payments, migrations, security-sensitive code.

Setup

  • Create risk:low, risk:medium, risk:high labels in the repo
  • Add risk criteria to contributing guide or PR template
  • Add reminder in PR template to apply the label before requesting review
  • Define who can override/escalate (suggested: tech lead)

How did you test this?

  • Tested on iOS
  • Tested on Android
  • Tested on a small device
  • Tested on a real device
  • Tested all flows related with this PR changes
  • Tested accessibility
  • Added tests

Verification

Check Result
pnpm lint Passed
pnpm type-check Passed
pnpm lint:translations Passed
pnpm test Passed
APP_ENV=production npx expo config --type public --json extra.router is { "sitemap": false }, plugin entry ["expo-router", { "sitemap": false }]
APP_ENV=development npx expo config --type public --json extra.router is { "sitemap": true }
APP_ENV=qa / APP_ENV=staging (same command) extra.router is { "sitemap": true }

Not yet verified on a device or emulator.

How to test locally

  1. Run a development build (pnpm start:development, then pnpm ios or pnpm android) and open <scheme>://_sitemap (e.g. npx uri-scheme open "RootstrapApp://_sitemap" --ios). The sitemap screen should list the app routes.
  2. Run APP_ENV=production npx expo config --type public --json and check that extra.router.sitemap is false.
  3. Optionally, with a production build (pnpm start:production), open the same link: it should land on the not-found screen.

Notes:

This only changes the default in the template. Projects that want the sitemap in production can set the sitemap option of the expo-router plugin to true in app.config.ts.


Screenshots / Previews

N/A (no UI changes).

Copilot AI balanced review requested due to automatic review settings November 3, 2026 12:05
@devs-rootstrap
devs-rootstrap requested a review from a team as a code owner November 3, 2026 12:05
@devs-rootstrap devs-rootstrap added the risk:low Config, copy, minor UI tweaks. Low blast radius. label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

💯 Test Coverage

Lines Statements Branches Functions
Coverage: 56%
56.23% (347/617) 59.18% (174/294) 48.76% (118/242)

😎 Tests Results

Tests Skipped Failures Errors Time
145 0 💤 0 ❌ 0 🔥 33.02s ⏱️
👀 Tests Details • (56%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files56.2359.1848.7656.9 
src/app/(app)37.544.442037.5 
   _layout.tsx70.5810037.570.5816–28, 82

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the change that disables the sitemap in production while preserving it for non-production debugging.

No open issues 🎉

What changed in this PR

Overall Review: ai:clean

Disables Expo Router’s sitemap route in production while preserving it as a debugging aid in non-production environments. No actionable findings remain.

Changes:

  • Sets the sitemap plugin option based on Env.APP_ENV.
  • Adds configuration tests for production, development, QA, and staging.
  • Documents sitemap availability and how projects can override the default.
File Description
docs/​src/​content/​docs/​guides/​navigation.mdx Documents environment-specific sitemap behavior and customization.
app.config.ts Disables the sitemap for production.
__tests__/​app-config.test.ts Checks sitemap configuration across all four environments.

Review effort: Balanced

@label-pr-severity-rs label-pr-severity-rs Bot added the ai:clean No significant issues label Nov 3, 2026

@fernandatoledo fernandatoledo left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@devs-rootstrap I left a few comments on this PR, please take a look.

Comment thread app.config.ts Resolved
Comment thread __tests__/app-config.test.ts Resolved
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

✅ Good news! We ran Expo Doctor for this PR and everything looks good, Great job!

@fernandatoledo
fernandatoledo merged commit 61bfc70 into master Nov 16, 2026
12 checks passed
@fernandatoledo
fernandatoledo deleted the fix/disable-sitemap-in-production branch November 16, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:clean No significant issues risk:low Config, copy, minor UI tweaks. Low blast radius.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants