Open joallard opened 1 year ago
server.origin
works in the repo you provide.
I assume this case happens in vue sfc component?
@sun0day Thanks for checking it out
I assume this case happens in vue sfc component?
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:
<img src="/path">
(the Vite logo): doesn't get subsitutedimport imageUrl from "/path"; <img src="{imageUrl}">
(the JS logo): gets substituted with the origin setting correctly.I wasn't sure, but from the docs on assets, this doesn't look like the behavior expected
If using the Vue plugin, asset references in Vue SFC templates are automatically converted into imports.
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 <img src="./path">
is transformed to import imageUrl from "/path"; <img src="{imageUrl}">
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.1Reproduction
https://stackblitz.com/edit/vitejs-vite-bghbn5
Steps to reproduce
Given
server.origin = "http://localhost:52125"
/
Expected: Tag
img#logo
containslocalhost
insrc
field Actual: Attributeimg#logo[src]
starts with/
(shows a relative path)System Info
Used Package Manager
yarn
Logs
No response
Validations