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

Image URLs from file loader no longer have asset prefix in 5.3.3 #37427

Closed
2 tasks done
mudge opened this issue Jan 9, 2023 · 2 comments · Fixed by #37429
Closed
2 tasks done

Image URLs from file loader no longer have asset prefix in 5.3.3 #37427

mudge opened this issue Jan 9, 2023 · 2 comments · Fixed by #37429
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@mudge
Copy link
Contributor

mudge commented Jan 9, 2023

Preliminary Checks

Description

Between Gatsby 5.3.2 and 5.3.3, image URLs generated by the file loader no longer include any configured asset prefix, e.g. the src URL for the following:

import logo from './images/logo.svg'

const SomeComponent = () => (
  <img src={logo} alt="" >
)

When built with gatsby build --prefix-paths and assetPrefix set to https://assets.example.com in gatsby-config.js should be prefixed with https://assets.example.com.

This seems to be caused by f448e12 as removing that change causes the asset prefix to be reinstated.

Reproduction Link

https://github.com/ghostcassette/gatsby-asset-prefix

Steps to Reproduce

  1. import an image in a React component and use it in an img tag, e.g.
import logo from "../images/icon.png"

const IndexPage = () => ( 
  <img src={logo} alt="" />
)
  1. Set assetPrefix to https://assets.example.com in gatsby-config.js
  2. Build the site with gatsby build --prefix-paths

Expected Result

The image URL should be prefixed with the asset prefix, e.g. https://assets.example.com/static/icon-decafbad.png

Actual Result

The image was not prefixed with the asset prefix but was relative to the current hostname, e.g. /static/icon-decafbad.png

Environment

System:
    OS: macOS 13.1
    CPU: (10) arm64 Apple M1 Max
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.13.0 - ~/.nodes/node-18.13.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.3 - ~/.nodes/node-18.13.0/bin/npm
  Languages:
    Python: 3.9.9 - /Users/mudge/.pyenv/shims/python
  Browsers:
    Chrome: 108.0.5359.124
    Firefox: 108.0.1
    Safari: 16.2

Config Flags

No response

@mudge mudge added the type: bug An issue or pull request relating to a bug in Gatsby label Jan 9, 2023
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 9, 2023
@tyhopp tyhopp added status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jan 10, 2023
@tyhopp
Copy link
Contributor

tyhopp commented Jan 10, 2023

Thank you for the repro and description!

@jt-nti
Copy link

jt-nti commented Jul 3, 2023

@tyhopp I think the same issue was introduced between 4.25.0 and 4.25.1 - do you know if the fix is likely to be included in 4.25.x at some point? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants