hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

[BUG] Sitemap doesn't work in Oxygen

Open beppek opened this issue 3 years ago • 8 comments

Describe the bug Sitemaps work fine when viewed locally in dev and preview mode. However, once deployed to Oxygen it returns a 404. We noticed this on our Oxygen deployments (private) and thought we should compare with other sites we know to be on Hydrogen+Oxygen.

https://skims.com/sitemap.xml <- 404 https://shopify.supply/sitemap.xml <- 404 https://denimtears.com/sitemap.xml <- All URLs point to the checkout subdomain i.e. https://denim-tears.myshopify.com (I assume they're using the sitemap auto generated by Shopify which means the tip to use that one in the docs is no good)

To Reproduce

  1. Deploy to Oxygen
  2. Visit yourdeployment.com/sitemap.xml

Expected behaviour Sitemaps should be generated

Additional context Add any other context about the problem here. eg.

  • Hydrogen version: 1.4.1 (not sure what the examples above are using)

beppek avatar Sep 20 '22 06:09 beppek

Hi! Thanks for reporting this. It seems the sitemap works in our demo-store so it might not be related to Oxygen but something in old versions of the demo-store. I've checked shopify.supply and the issue was indeed related to using an old version of sitemap.xml.server.ts, which is probably what's happening in other projects too.

I assume you are testing with the latest version in your project but we just discovered a bug in that file that shows up in certain conditions. Can you try this fix and see if it works for you? It's weird that it works for you in development, though... maybe it's an issue different from shopify.supply and the others 🤔

frandiox avatar Sep 20 '22 08:09 frandiox

Hi @frandiox thanks, but it didn't work. We're still getting a 404. Interestingly the server logs say it's a 200 and no other information in the logs.

beppek avatar Sep 21 '22 04:09 beppek

We haven't made any other changes to the sitemap.

beppek avatar Sep 21 '22 04:09 beppek

@beppek It turns out Oxygen does not serve /sitemap.xml and /robots.txt for public preview deployments to avoid indexing issues.

It should work for the production deployment (when using a custom domain) and for private deployments as well. Can you check that? We should definitely document this.

frandiox avatar Sep 22 '22 11:09 frandiox

Ok, I see. Our production deployment isn't using a custom domain yet and we had to take it public so you could investigate our slow response times. Taking it private the sitemap doesn't return a 404 anymore, instead it crashes with the following error: error on line 1392 at column 34: xmlParseEntityRef: no name, which is strange because it doesn't crash when running local preview. Same code, same data.

No further info in the server logs.

beppek avatar Sep 26 '22 00:09 beppek

@beppek Does it render at all when running locally in dev mode? What about running a deploy preview locally?

blittle avatar Sep 26 '22 21:09 blittle

@blittle yes, it works fine in both dev and preview mode locally.

beppek avatar Sep 26 '22 23:09 beppek

Ah no, sorry, I had env variables for a different store running. It works in preview mode locally, but not in dev mode locally.

beppek avatar Sep 26 '22 23:09 beppek