Skip to content

Static Assets Use Absolute URLs Instead of Relative URLs #3892

@creepysta

Description

@creepysta

Summary

When hosting hub.getdbt.com behind a reverse proxy or in a custom environment, static assets (e.g., JS, CSS) are prefixed with the absolute static_url (e.g., https://hub.getdbt.com/image/...), causing broken references when the site is served from a different domain or path.

Problem

Currently, all static assets are referenced using a static_url prefix, which is hardcoded to be either:

  • http://localhost:4567 (in dev)
  • https://hub.getdbt.com (in prod)
    This approach causes problems when deploying the site behind a reverse proxy or on a custom domain (e.g., https://internal.myorg.com/dbt-hub), as the asset URLs still point to the original domain.

Suggested Fix

  • Remove the hardcoded static_url prefix from asset links and instead:
  • Use relative URLs in templates and static references
  • Optionally allow configuring a base_path or asset_prefix if advanced customization is needed
    eg;
--- a/source/_nav.erb
+++ b/source/_nav.erb
-                       <img src='<%= site_url %>/img/logos/dbt-lockup.png' style="height: 48px"/>
+                       <img src='/img/logos/dbt-lockup.png' style="height: 48px"/>

or in config.rb -

set :host, ENV[''MM_HOST] || 'hub.getdbt.com'
set :base_prefix ENV['MM_BASE_PREFIX'] || "/"
... 
helpers do
  def host_with_port
    [[config[:host], config[:base_prefix]].compact.join("/"), optional_port].compact.join(':')
  end

  def optional_port
    config[:port] unless [80, 443].include? config[:port].to_i
  end

  def site_url
    config[:protocol] + host_with_port
  end
end 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions