-
-
Notifications
You must be signed in to change notification settings - Fork 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
vite dev
can't set base url like vite build
#2714
Comments
I have the same issue with backend integration. We work with many frontends to one backend and we can't server the assets by the same backend. This PR #1556 implements the use of the I get a workaround adding a With this, I just need that the backend return the HTML with: <!-- APP 1 -->
<div id="app"></div>
<script type="module" src="http://localhost:3000/@vite/client"></script>
<script type="module" src="http://localhost:3000/src/main.ts"></script>
<!-- APP 2 -->
<div id="app"></div>
<script type="module" src="http://localhost:3001/@vite/client"></script>
<script type="module" src="http://localhost:3001/src/main.ts"></script> And my // https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
baseAssetUrl: 'http://localhost:3000/',
server: {
hmr: {
path: '/',
host: 'localhost',
port: 3000,
protocol: 'ws'
}
}
}) Now, when access the backend URL, I just get the root HTML from backend and the scripts, styles and assets from Vite Server. I believe that the |
@edersoares I'm looking at your workaround and I don't quite understand how would it make any difference. Could you explain? |
@wvffle sure! In development, we have a backend host running on Our backend serve only the root HTML for The problem is that the assets in Vue projects are requested with root path For this, we need that the assets URL should returned with frontend URL, so, when we access The command @wvffle did you undersand? |
Yeah, I get that, thanks @edersoares! However, I need As a workaround I've added a proxy from backend to vite for the public routes and |
@wvffle could you share your solution? |
I'm using django as a backend. Here is my solution: https://github.com/wvffle/django-e2ee-chat/blob/1c9d434caa174f8a761504affe49517ce33f3036/chat/urls.py#L17-L28 I simply pass all of the requests to I'm already using docker for my dev env so I might switch to using haproxy instead somewhere in the future. |
Describe the bug
I follow the Backend Integration section so that I can use koa to serve my app.
But I can't load assets files like image. Just like this..
Reproduction
Sorry I can't upload the project to the github. I just follow the document, and I want the prefix address of the static resource to be converted from the root directory to the base that I set.
System Info
Output of
npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:Used package manager: yarn
Logs
Before submitting the issue, please make sure you do the following
The text was updated successfully, but these errors were encountered: