cli: [Bug]: When loading fonts via asset_url or file_url, the fonts are loaded from localhost/cdn instead of shopify/cdn
Please confirm that you have:
- Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
- Reproduced the issue in the latest CLI version.
In which of these areas are you experiencing a problem?
Theme
Expected behavior
Should load fonts from //augusta-and-adeline.myshopify.com/cdn/
and not //localhost/cdn/
Actual behavior
Fonts are trying to load from //localhost/cdn/
which does not exist.
Reproduction steps
- Create an @font face rule:
src: url("{{ 'font.name' | asset_url }}") format("woff2")
- Get the error.
Operating System
Windows 10
Shopify CLI version (check your project’s package.json
if you’re not sure)
3.49.3
Shell
powershell
Node version (run node -v
if you’re not sure)
18.17.1
What language and version are you using in your application?
No response
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 1
- Comments: 22 (7 by maintainers)
Still an issue.
Hello!
I do have the same issue for a longer time now. The custom fonts are not loading when I run the theme locally, but when I open the preview on the cloud it works as expected. It seems to happen since a CLI Update.
Here you can see the fonts are loading from local host in the source code:
But in the console I do receive a CORS error while trying to load the font from the Shopify CDN:
I don’t know why it is mixed up that way and hope this info helps to solve the issue.
Bumping. We also have this issue. I was able to get around at least the font issue by setting the
SHOPIFY_CLI_BUNDLED_THEME_CLI
flag:But I still have an issue with other assets (images and JS). I work on a single store, and am having this issue in both Firefox dev edition and Chrome.
I do work on quite a few different shopify sites and switch around frequently. I wonder if logging out completely and logging back in to shopify could possibly solve the issue. Will try next time I am working on it.
I have the presumption, that the issue is maybe initiated when you change the Shopify system and theme you are working on.
For example, when you work for different customers on various Shopify systems. So maybe there is some kind of cache interfering here.
I can currently not reproduce it because the development themes stay active for one week and I need to work on different themes every day.
I will further observe the issue to clarify the reason for it.
Custom fonts are loading as expected on my end from local.
@shopify/cli/3.49.3
Oh, yes in Firefox it seems to be even more difficult. There are JS files also not loading anymore: