-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
server.origin is not substituted in image tag #85
Comments
@sun0day Thanks for checking it out
Indeed. Edit: Ah, sorry! I thought the initial case was already a Vue template being rendered. I updated the repo to use a SFC template. From what I can see, in the test repo, we have two cases of image:
I wasn't sure, but from the docs on assets, this doesn't look like the behavior expected
Edit 2: However, if I switch the path to a relative path, I think it works. I suppose that's the way it works? Edit 3: One more note about this: plugin-vue explains in Asset URL Handling how |
related: vitejs/vite#4836 |
Vite is supposed to prefix asset [1] URLs with the base / origin, and you can see this working for url() in CSS (otherwise the Wikidata logo would be broken), but due to vitejs/vite-plugin-vue#85 [2] this doesn’t work for <img> src= attributes. Work around it by importing the importing the files and then using that URL dynamically. (In the tests, we need to map those imports to a fake module so Jest doesn’t try to load the real file content as JS source.) [1]: https://vitejs.dev/guide/assets.html [2]: vitejs/vite-plugin-vue#85 Bug: T335754 Change-Id: Ie3c1cf9c225c646b2f7d94727a634e9ff78aad4e
Hi there, does this issue still persists? |
Describe the bug
Working from an alternate host following the docs about Backend Integration, when I set
server.origin
to another host, the src links for my image tags are not getting substituted.I'm working from the Backend Integration docs that says the following:
In my local case:
script
tag at the bottom of the page successfully gets replaced with the server origin. The images tag do not.I am half convinced I am missing something relatively obvious here, but I can't find what. (I even upgraded from Vue 2 to 3 in the process to make sure) For instance, I'm not sure if there's a better location for my image asset than in
/public
(I didn't find in the docs or on the web a better directory structure for it), or whether there's a special syntax for the src. If this isn't a supported case, I'd be happy to help improve the docs to clarify that situation.Other issues consulted
Searching for
server.origin
in the Issues:vitejs/vite#7778: Tentatively fixed by writing the docs that are written above
vitejs/vite#5104: Implemented
server.origin
vitejs/vite#9849, vitejs/vite#9851: Recent from last August; appears to have been fixed before v4.0.1 used in repro
vitejs/vite#8116, vitejs/vite#8077: May 2022, precedes current v4.0.1
Reproduction
https://stackblitz.com/edit/vitejs-vite-bghbn5
Steps to reproduce
Given
server.origin = "http://localhost:52125"
/
Expected: Tag
img#logo
containslocalhost
insrc
fieldActual: Attribute
img#logo[src]
starts with/
(shows a relative path)System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: