DEV Community

Discussion on: How to generate /sitemap.xml route in Remix framework

Collapse
 
numananees profile image
Numan Anees • Edited

For generating the siteURL dynamically you can also use the following code.

 const host =
      request.headers.get("X-Forwarded-Host") ?? request.headers.get("host");
    if (!host) {
      throw new Error("Could not determine domain URL.");
    }
    const protocol = host.includes("localhost") ? "http" : "https";
    const siteUrl = `${protocol}://${host}`;
Enter fullscreen mode Exit fullscreen mode
Collapse
 
burhanharoon profile image
Burhan Haroon

Thanks for the suggestion. I'll add that up to the article. Thanks again! Cheers!