reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
19.01k stars 1.07k forks source link

[REF-3107] Dynamic domain in sitemap #3489

Open benedikt-bartscher opened 2 months ago

benedikt-bartscher commented 2 months ago

Currently, reflex generates sitemaps with a static domain. If you want to deploy the same codebase to 2 different domains, one would need to build 2 different docker images.

Possible Solutions:

Both solutions would require us to move the sitemap serving from frontend to backend. Maybe there is a solution via nextjs which does not require this.

REF-3107

TG199 commented 2 months ago

Hi, I'd to try this out.

benedikt-bartscher commented 1 month ago

@TG199 do you still want to try this?

TG199 commented 1 month ago

Oh, yes I'll.

TG199 commented 1 month ago

Hi @benedikt-bartscher ,

I have a few questions regarding the sitemap generation process, particularly about the differences between Reflex hosting and self-hosting.

  1. Is the sitemap generation issue specific to Reflex hosting or self-hosting environments?
  2. Are there any special configurations or scripts that Reflex hosting uses for sitemap generation that are different from self-hosting? I've implemented the placeholder domain constant and updated the generate_sitemap_config function, but I'm still facing inconsistencies. Any guidance or insights would be greatly appreciated.

Thank you!

benedikt-bartscher commented 1 month ago

Hi @TG199, thank you for looking into this.

  1. I don't know the internals of reflex hosting very well, but sitemap generation should be pretty much independent of the deployment environment.
  2. I don't think so. Could you create a draft PR to showcase what you tried? What kind of inconsistencies did you experience?

As mentioned in the Issue description, reflex currently serves the sitemaps as part of the frontend. This means that the whole sitemap (including the deployment domain) is baked into the frontend.zip during export. This comes with multiple limitations:

To improve this, we would first need to move sitemap generation and serving to the backend. Ideally, this should create the same sitemap for the same code (no breaking change). It could be as easy as iterating to all pages registered to the rx.App. We could later introduce some cool apis for dynamic sitemap generation.