Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

URLs are not supported in production public_path due to leading slash #83

Open
gkaemmer opened this issue Feb 23, 2017 · 3 comments
Open

Comments

@gkaemmer
Copy link

Hello! Loving webpack-rails, really has been a game changer getting our code migrated away from sprockets.

We deliver our assets from a CDN, so it makes sense for us to define config.webpack.public_path = '//cdn.url.com/assets/webpack'. The problem with this is that manifest.rb always adds a slash before the public path.

Weirdly, the resulting URLs (like "///sub.domain.com/assets/webpack/app.js") work in most browsers, but not all! In IE11 and other old browsers, the public path gets parsed incorrectly, prevent the assets from being loaded.

A workaround is removing one (but not both) of the leading slashes on our CDN url. But this is pretty weird. Is there another way to tell webpack to load assets from another domain?

@mipearson
Copy link
Owner

Hm, not off the top of my head. If you can think of a way to solve this without making our configuration more complex than it already is, submit a PR or suggestion.

@gkaemmer
Copy link
Author

gkaemmer commented Feb 24, 2017

Cool. I'll take a look soon. I think that doing some simple checks on Rails.configuration.webpack.public_path would be sufficient:

is_url = Rails.configuration.webpack.public_path =~ /^(https?:)?\/\//
# Add slash unless is_url

@juanca
Copy link

juanca commented Feb 24, 2017

We also use CDN for our frontend assets but do not configure webpack with any of it. Instead, we rely on the rails assets host to be configured properly. I think that should suffice for your case as well.

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

No branches or pull requests

3 participants