Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding asset_host results in incorrect asset paths #71

Open
optimuspwnius opened this issue Nov 19, 2021 · 0 comments
Open

Overriding asset_host results in incorrect asset paths #71

optimuspwnius opened this issue Nov 19, 2021 · 0 comments

Comments

@optimuspwnius
Copy link

When the Rails app is configured with an asset_host the urls for the importmap look good until you override the asset_host in the controller. Eg:

config/environments/production.rb

config.asset_host = "https://cdn.example.com"

app/controllers/admin_controller.rb

class AdminController < ApplicationController
  self.asset_host = "https://cdn-admin.example.com"
end

The html output in the admin view has the wrong asset host. It has cdn.example.com instead of cdn-admin.example.com.

<script type="importmap" data-turbo-track="reload" nonce="">{
  "imports": {
    "application": "https://cdn.example.com/assets/application-11b28290a99e06bbb97f89de85099237219c655f.js",
    "admin": "https://cdn.example.com/assets/admin-c574738f5c1adffd9b7a877bf36ca6320be01a06.js",
    "@hotwired/turbo-rails": "https://cdn.example.com/assets/turbo-b993120d6c7ae1a4f86fc1faf67a6d7d462fa2f0.js",
    "@hotwired/stimulus": "https://cdn.example.com/assets/stimulus-33b5690d111cc0620be9dd1b12e236dacf03a024.js",
    "@hotwired/stimulus-loading": "https://cdn.example.com/assets/stimulus-loading-e6cc58d8195016dd774d85da7a37d34620facbfd.js",
    "controllers/hello_controller": "https://cdn.example.com/assets/controllers/hello_controller-8404a78da18e60f56632427531b2407db4f7f75e.js"
  }
}</script>
<link rel="modulepreload" href="https://cdn.example.com/assets/application-11b28290a99e06bbb97f89de85099237219c655f.js" nonce="">
<link rel="modulepreload" href="https://cdn.example.com/assets/admin-c574738f5c1adffd9b7a877bf36ca6320be01a06.js" nonce="">
<script src="https://cdn-admin.example.com/assets/es-module-shims.min-6e2591c8c15bae03d37b0f75efe46d7c609ef6e4.js" async="async" data-turbo-track="reload" nonce=""></script>

Love the work you guys are doing! ❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant