chore: update sitemap default host to use ENV variable

- Change default_host assignment to use ENV.fetch for
  RAILS_SITEMAP_DEFAULT_HOST
- This allows for easier configuration based on the environment,
  particularly useful for production and development setups.
This commit is contained in:
songtianlun 2025-02-17 14:08:31 +08:00
parent df86a10f03
commit 81116a2f3e

View File

@ -4,7 +4,7 @@ class RefreshSitemapWorker
def perform
host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000"
Rails.application.routes.default_url_options[:host] = host
SitemapGenerator::Sitemap.default_host = "https://pub.r2.todayaiweather.com"
SitemapGenerator::Sitemap.default_host = ENV.fetch("RAILS_SITEMAP_DEFAULT_HOST", host)
if Rails.env.production?
SitemapGenerator::Sitemap.adapter = SitemapGenerator::AwsSdkAdapter.new(
ENV.fetch("AWS_BUCKET", Rails.application.credentials.dig(:aws, :bucket)),