Skip to content

fix: repair sitemap Mongo source fallback for blog URLs - #1

Open
princepspolycap wants to merge 1 commit into
mainfrom
fix/sitemap-mongodb-env-fallback
Open

fix: repair sitemap Mongo source fallback for blog URLs#1
princepspolycap wants to merge 1 commit into
mainfrom
fix/sitemap-mongodb-env-fallback

Conversation

@princepspolycap

Copy link
Copy Markdown

Problem

https://www.princepspolycap.com/sitemap-0.xml is missing /blogs/* URLs in production. Current output only contains static routes.

Root Cause

next-sitemap.config.js only reads process.env.MONGODB_URI, while runtime code paths in this repo use MONGODB_DATABASE_URL (and optional DB name envs). In deploy contexts where only MONGODB_DATABASE_URL is set, sitemap blog query returns no rows.

Changes

  • Updated sitemap config to resolve Mongo URI from either MONGODB_DATABASE_URL or MONGODB_URI.
  • Added optional DB name resolution from MONGODB_DB_NAME or COSMOS_DB_DATABASE_NAME during sitemap DB connect.
  • Expanded publish filter to include both models:
    • { status: "published" }
    • { isPublished: true }

File changed

  • next-sitemap.config.js

Testing (compute sandbox)

  • npm install
  • npm run build
  • Confirmed next-sitemap runs successfully in postbuild.
  • Baseline check (public): current sitemap-0.xml still has 4 URLs before this PR deploy.

Notes

  • Canonical + OG metadata are already present in src/app/blogs/[slug]/page.js.
  • After merge, deployment must complete, then validate public sitemap and submit to GSC/Bing.

@github-actions

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://brave-pebble-073f29e0f-1.eastus2.3.azurestaticapps.net

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.

1 participant