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

Wrong asset path being requested #919

Open
russellbrown opened this issue Mar 14, 2022 · 9 comments
Open

Wrong asset path being requested #919

russellbrown opened this issue Mar 14, 2022 · 9 comments

Comments

@russellbrown
Copy link

Version 4.3.0, rails 5.2.7, sass 3.6.0, sass-rails 5.0.7, sassc 2.0.0, sassc-rails 2.1.0

For some reason ckeditor is requesting the wrong URL for icons_hidpi.png with the result that none of the button icons are visible. It happens in both development and production.

Expected request: /assets/ckeditor/skins/moono-lisa/icons_hidpi.png
Actual request: /icons_hidpi.png

The request originates from the moono-lisa skin's editor.css where I would expect the compiled output to contain:

background:url(icons_hidpi.png?t=c264cac)...

However the actual compiled output includes a forward slash at the start, making it an absolute URL instead of relative:

background:url(/icons_hidpi.png?t=c264cac)...

The file itself is being served at the expected location in both development and production, so it isn't an issue with the png not being precompiled etc. window.CKEDITOR_BASEPATH is correct so that can't be the issue either. And I've tried clearing the assets cache but that made no difference.

All the other scripts are being loaded correctly and the editor is fully functional otherwise. I'm completely baffled - any ideas why this might be happening? Thank you.

@javierm
Copy link

javierm commented Mar 16, 2022

We're also running into this issue when trying to upgrade from Rails 5.2.6 to Rails 5.2.6.3. With Rails 5.2.6, it correctly returns the URL without the slash at the start.

@javierm
Copy link

javierm commented Mar 16, 2022

According to our tests, the issue seems to be related with upgrading sprockets from 4.0.2 to 4.0.3 (which we were including as part of the mentioned Rails upgrade).

@russellbrown
Copy link
Author

Thanks @javierm - I downgraded sprockets-rails from 3.4.2 to 3.2.2 and now it's using the correct URL.

@jakevose
Copy link

We're having the same issue and regressing sprockets-rails fixed it for us as well. h/t

@javierm
Copy link

javierm commented Aug 23, 2022

It's working for me with Sprockets 4.0.3 after upgrading to Rails 5.2.8.1. Instead of URLs like background:url(/assets/ckeditor/plugins/icons.png?t=...) (which I got with Rails 5.2.6.3 and Sprockets 4.0.3), now the application generates URLs like background:url(https://mydomain.com/assets/ckeditor/plugins/icons.png?t=...), and so the button icons are visible again.

@PatrickKing
Copy link
Contributor

PatrickKing commented Dec 21, 2022

Ended up addressing this in an old app by adding a route with a redirect. This works around the problem if you can't update Sprockets.

# config/routes.rb

  get 'icons_hidpi.png', to: redirect('/assets/ckeditor/skins/moono-lisa/icons_hidpi.png')

@dougjohnston
Copy link

Just had this same issue and was able to track it to a move from sprockets-rails 3.2.2 to 3.4.2. More importantly, I noticed that 3.4.2 introduced a new config value to use the legacy asset url approach (rails/sprockets-rails@67c74ec).

Setting that new config value fixed it for me:

# application.rb
config.assets.resolve_assets_in_css_urls = false

@bjer
Copy link

bjer commented Aug 28, 2023

Ended up addressing this in an old app by adding a route with a redirect. This works around the problem if you can't update Sprockets.

# config/routes.rb

  get 'icons_hidpi.png', to: redirect('/assets/ckeditor/skins/moono-lisa/icons_hidpi.png')

This fixed it for me on an app running Rails 6.1.7.6

@streeet25
Copy link

streeet25 commented Jan 19, 2024

Ended up addressing this in an old app by adding a route with a redirect. This works around the problem if you can't update Sprockets.

# config/routes.rb

  get 'icons_hidpi.png', to: redirect('/assets/ckeditor/skins/moono-lisa/icons_hidpi.png')

This fixed it for me on an app running Rails 6.1.7.6

Also only this solution help to fix error on Rails 5.2.8.1 with only one difference i have error with 'icons.png'

# config/routes.rb
get 'icons.png', to: redirect('/assets/ckeditor/skins/moono-lisa/icons.png')

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

7 participants