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

[@astrojs/image] remote images with protocol-relative URLs fail to fetch on build #4925

Closed
1 task done
hugo-t-b opened this issue Sep 30, 2022 · 0 comments · Fixed by #5072
Closed
1 task done

[@astrojs/image] remote images with protocol-relative URLs fail to fetch on build #4925

hugo-t-b opened this issue Sep 30, 2022 · 0 comments · Fixed by #5072
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: image Related to the `@astrojs/image` package (scope)

Comments

@hugo-t-b
Copy link

What version of astro are you using?

1.4.0

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Linux

Describe the Bug

When a remote image with a protocol-relative URL (starting with //) is passed to @astrojs/image, it works in development, but on build it throws image could not be fetched. This issue occurred due to Contentful returning this type of URL for assets.

This could probably be fixed by checking for protocol-relative URLs and replacing them with https ones.

In the meantime, the following is a decent solution:

<Image src={`https:${protocolRelativeImageUrl}`} ... />`

Note about reproduction: it appears that when using Stackblitz, remote images not using https don't work at all, so it may be best for the reproduction to be opened locally (Stackblitz has a download button).

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-drwgkz?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@matthewp matthewp added pkg: image Related to the `@astrojs/image` package (scope) - P3: minor bug An edge case that only affects very specific usage (priority) labels Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: image Related to the `@astrojs/image` package (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants