# Bad source map path in subfolder install

**URL:** <https://meta.discourse.org/t/bad-source-map-path-in-subfolder-install/130241>\
**Category:** Bug\
**Created:** [4 באוקטובר,‏ 2019,‏ 12:28pm UTC](https://meta.discourse.org/t/bad-source-map-path-in-subfolder-install/130241 "2019-10-04T12:28:19Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [4 באוקטובר,‏ 2019,‏ 12:28pm UTC](https://meta.discourse.org/t/bad-source-map-path-in-subfolder-install/130241/1 "2019-10-04T12:28:19Z")

</div>

My subfolder install kept giving errors in Firefox console about the fact that it is unable to find source maps.

`Source map error: request failed with status 404 Resource URL: [https://redacted.com/community/assets/admin-…1d82fc1b0c7d1f24b7b71256a4eb4860f1aa96444925a361d8c24425c.js](https://redacted.com/community/assets/admin-e1c3cbc1d82fc1b0c7d1f24b7b71256a4eb4860f1aa96444925a361d8c24425c.js) Source Map URL: /assets/admin-e1c3cbc1d82fc1b0c7d1f24b7b71256a4eb4860f1aa96444925a361d8c24425c.js.map`

As you can see, the `/community` path prefix is missing from the source map URL.

So I did a little digging.

`lib/tasks/assets.rake` does this:

```plaintext
  assets = cdn_relative_path("/assets")
  source_map_root = assets + ((d = File.dirname(from)) == "." ? "" : "/#{d}")

```

Now `cdn_relative_path` in `lib/global_path.rb` looks like this.

```
module GlobalPath
  def path(p)
    "#{GlobalSetting.relative_url_root}#{p}"
  end

  def cdn_path(p)
    GlobalSetting.cdn_url.blank? ? p : "#{GlobalSetting.cdn_url}#{path(p)}"
  end

  def upload_cdn_path(p)
    if SiteSetting.Upload.s3_cdn_url.present?
      p = Discourse.store.cdn_url(p)
    end

    (p =~ /^http/ || p =~ /^\/\//) ? p : cdn_path(p)
  end

  def cdn_relative_path(path)
    if (cdn_url = GlobalSetting.cdn_url).present?
      URI.parse(cdn_url).path + path
    else
      path
    end
  end

```

As you can see, both `cdn_path` and `upload_cdn_path` eventually call the `path` method which makes sure that the subfolder is being prefixed. However, `cdn_relative_path` does not call the `path` method, it just returns its parameter (called… `path`).

BTW I think cdn\_path needs to return `path(p)` in the middle part of the ternary as well?

---

_[View the full topic](https://meta.discourse.org/t/bad-source-map-path-in-subfolder-install/130241)._
