-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Local image resolution from external dns address #6128
Comments
Link to Minimal Reproducible Examplehttps://stackblitz.com/edit/github-ocszci To continue the conversation from #7819 ...
This problem is very annoying, as it now prevents us from using Assets in production, and have to fall back to 'normally' loading (unoptimised) images until this has been resolved. (In my view this is a P4: Important Bug) I don't really understand why the |
There's multiple reasons, some of which the endpoint doesn't really handle but should eventually:
This is not an optimal solution since it's a bit of work, but you could make your own endpoint in the meantime. It just has to call the image service's hooks and read from the filesystem like you suggest. |
Thank you @Princesseuh for clarifying. I guess I'll have to go the custom endpoint route then. (https://docs.astro.build/en/reference/image-service-reference/#local-services). |
We've removed |
@matthewp This issue also applies to |
What version of
astro
are you using?1.6.13
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
yarn
What operating system are you using?
Mac
Describe the Bug
I am developing a website on my mac system, for testing purposes I use my phone to browse it in my home wifi. My modem is configured to resolve my mac-hostname to it's address, so inside my phone I open for example
http://arash-mac:3000
. But inside my mac, I have other dns servers configured, which means it cannot resolve it's own address. Inside@astrojs/image
there's a line that tries to resolve local images through whatever hostname that they are requested through. In this case, it tries to resolvehttp://arash-mac:3000/_image/etc
instead ofhttp://localhost:3000/_image/etc
.At following line of code, when
isRemoteImage
returns false,url.origin
is used as is, which in this complex scenario cannot be resolved into local machine. I did fix it by patching it intonew URL(transform.src, 'http://localhost:' + url.port)
, however I believe the code design is problematic on a different level (trying to fetch local images through http queries).https://github.com/withastro/astro/blob/main/packages/integrations/image/src/endpoint.ts#L33
Link to Minimal Reproducible Example
not applicable
Participation
The text was updated successfully, but these errors were encountered: