Replies: 2 comments 1 reply
-
|
server.origin only affects asset URLs generated by plugins, not the core HTML transforms Vite injects (the /@vite/client script, /src/ imports). |
Beta Was this translation helpful? Give feedback.
-
|
puedes configurar el base y el server.origin en vite.config para que genere las urls absolutas apuntando al servidor de vite: // vite.config.ts
export default defineConfig({
server: {
origin: "http://localhost:5173",
}
})con eso el html que devuelve vite ya incluye la url completa en vez del path relativo, asi cuando tu backend de go sirve el html los scripts apuntan al sitio correcto. basicamente le dices a vite desde donde se van a cargar sus assets |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
In a Go backend dev setup, I’m fetching
index.htmlfrom the Vite dev server and then serving it from a different origin (e.g.http://localhost:8080).By default, the HTML returned by Vite includes root-relative paths like:
When this HTML is re-served from another origin, those paths resolve incorrectly.
Is there a supported way to make the dev server emit fully-qualified URLs (e.g.
http://localhost:5173/@vite/client) in the injected HTML?I’ve tried setting
server.origin, but the returned HTML still contains root-relative paths.Is this possible ?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions