All jobs

Add a Sitemap to a Nuxt App

Yes. An agent adds a Nitro route that builds sitemap.xml from the app's pages and TMDB data, updates robots.txt, tests it with Vitest and Playwright and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads the page tree and where its data comes from. In an app shaped like nuxt/movies, nuxt.config.ts loads @vueuse/nuxt, @unocss/nuxt, @nuxt/image, @nuxtjs/i18n with a no_prefix strategy over fourteen locales, and @nuxtjs/html-validator, sets a routeRules entry of cache-control: private, no-store on /**, and exposes apiBaseUrl in the public runtime config. The pages under app/pages are index.vue, [type]/index.vue and [type]/[id].vue for movie and tv, [type]/category/[query].vue, genre/[no]/movie.vue and tv.vue, person/[id].vue and search.vue. app/composables/tmdb.ts fetches from the proxy with listMedia, getGenreList and getTrending, and app/constants/lists.ts names the popular, top_rated, upcoming, now_playing and airing_today queries. public/robots.txt allows everything and names no sitemap. The server/ directory holds one api/index.ts handler, and the i18n strategy means every locale shares one URL, so no alternate-language entries are needed.

It adds server/routes/sitemap.xml.ts, a Nitro handler that builds the URL list from three sources: the static paths /, /movie, /tv and /search; one /{type}/category/{query} per entry in QUERY_LIST; and the genre pages from genre/movie/list and genre/tv/list on the proxy, plus the first pages of popular and top_rated movies and shows as /movie/{id} and /tv/{id} entries. The proxy calls use $fetch with the same tmdb base path the composable uses, with the list builder in a separate server/utils/sitemap.ts so it can be tested without a network. The handler sets Content-Type: application/xml and returns the <urlset>, and a routeRules entry for /sitemap.xml replaces the global no-store header with a public cache for that path. public/robots.txt gains a Sitemap: line.

Tests follow the two suites the repository has. A unit test in tests/unit/sitemap.test.ts, under the vitest.config.ts include patterns, feeds the builder fixed lists and asserts each path appears once with the site origin. A Playwright test beside tests/e2e/homepage.spec.ts fetches /sitemap.xml through @nuxt/test-utils/playwright, asserts the content type and that the body contains /movie and /tv. htmlValidator already ignores paths ending in .xml, so the validator does not try to parse it.

The agent runs pnpm run lint, pnpm run typecheck and pnpm run test:unit, the three steps of .github/workflows/tests-unit.yml, then pnpm run test:e2e as tests-e2e.yml does, with pnpm 11 and Node 24 as package.json's devEngines require. It builds the app with pnpm run build, starts it with pnpm run start and pastes the first lines of curl http://localhost:3000/sitemap.xml in the pull request.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add a sitemap to this Nuxt app and open a pull request. Read package.json, nuxt.config.ts, app/app.vue, every file under app/pages, app/composables/tmdb.ts, app/constants/lists.ts, server/api/index.ts, public/robots.txt, vitest.config.ts, playwright.config.ts, tests/e2e/homepage.spec.ts and the workflows under .github/workflows first. Add server/routes/sitemap.xml.ts, a Nitro handler returning application/xml, with the URL list built in server/utils/sitemap.ts from the static pages, one category page per QUERY_LIST entry, the genre pages from the proxy's genre lists, and the first page of popular and top rated movies and TV shows as item pages, using the same tmdb base path as the composable. Add a routeRules entry so /sitemap.xml is publicly cacheable instead of no-store. Add a Sitemap line to public/robots.txt. Add tests/unit/sitemap.test.ts for the builder with fixed input and an e2e test beside homepage.spec.ts asserting the content type and that /movie and /tv appear. Run pnpm run lint, pnpm run typecheck, pnpm run test:unit and pnpm run test:e2e, then build and start the app and paste the first lines of curl against /sitemap.xml in the pull request. Do not change the i18n configuration or any page.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request with a new handler and a new util under server/, one routeRules entry in nuxt.config.ts, one line in public/robots.txt, and two test files. The description shows the start of the real sitemap.xml from the built server, with the static, category, genre and item entries, and the lint, typecheck, unit and e2e summaries.

On a repository with the Tests unit and Tests e2e workflows, the pull request runs lint, typecheck and Vitest, then Playwright on the four configured browser projects, so a handler that throws when the proxy is slow, or a routeRules entry that breaks the global header, fails there.

A reviewer checks that the site origin is right for production, that the handler degrades to the static entries when the proxy fails rather than returning a 500, and that the number of item pages listed is one they are comfortable publishing. Then they submit the sitemap in Search Console.

Run it on every new content section added

A media site that adds sections over time starts one POST /o/{org}/sessions with this prompt whenever a new page directory lands, with the repository in resources. The run reads the current app/pages tree and the builder, adds the new paths and their dynamic entries, extends the unit test and opens one pull request.

With a webhook_url on the key, run.completed arrives with the session_url so the pull request link can be posted where the content team will see it.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A sitemap that lists dynamic pages depends on an upstream API, a cache header that the global routeRules would otherwise override, and a validator that must leave XML alone; each of those is a small thing a laptop run skips. In a Rush sandbox the agent runs all four test and lint steps the workflows run, builds the production server and requests the sitemap from it, and keeps the output in the run's record with the pull request.

The Playwright suite here runs on four browser projects, which is slow on a laptop and free of distractions in the sandbox. The turn parks when it finishes, and a follow-up to add <lastmod> from the proxy's release dates wakes it where it stopped.

Frequently asked questions

Why not use the @nuxtjs/sitemap module?

The module is a good choice when you want routes crawled automatically. A Nitro handler keeps the list explicit, needs no new dependency and is tested like the rest of server/. The pull request notes the module as the alternative if the list grows past what a handler should fetch per request.

Does the sitemap need one entry per locale?

No. The i18n strategy is no_prefix, so every locale lives at the same URL and the language is chosen by cookie or browser setting. The sitemap lists each path once.

What happens if the TMDB proxy is down?

The builder catches the fetch error, logs it and returns the static and category entries, so the route answers 200 with a shorter list rather than a 500. The unit test covers the fallback with a rejected fetch.

Will the no-store header still apply to pages?

Yes. The global /** rule is unchanged; the new routeRules entry applies only to /sitemap.xml, and the e2e test reads the header to confirm it.

More Nuxt jobs

The same job on other stacks

Keep reading