Asset Not Loaded When Integrating With Existing Backend
See original GitHub issueDescribe the bug
When I import an asset
import audio from "./do.mp3";
audio
resolves to something like base/**/do.mp3
in development mode. I am integrating Vite into an existing backend. The backend is running at localhost:4000
and vite is running at localhost:3000
. So during development, the existing backend at localhost:4000
does not yet have base/**/do.mp3
.
For production though, it works fine, vite build
will produce the files that the existing backend at localhost:4000
will be able to serve
I think that this should be noted in the docs or maybe audio
can resolve to something like localhost:3000/base/**/do.mp3
instead
Reproduction
https://stackblitz.com/edit/vitejs-vite-kkwd9h?file=src/main.js
System Info
System:
OS: macOS 12.3.1
CPU: (8) arm64 Apple M1 Pro
Memory: 179.39 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
Yarn: 1.22.18 - ~/.nvm/versions/node/v16.14.2/bin/yarn
npm: 8.6.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
Browsers:
Chrome: 100.0.4896.88
Safari: 15.4
npmPackages:
vite: ^2.9.1 => 2.9.1
Used Package Manager
yarn
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Backend Integration
Also make sure the server is configured to serve static assets in the Vite working directory, otherwise assets such as images won't be...
Read more >Adding assets and images
Loading Flutter assets in Android On Android the assets are available through the AssetManager API. The lookup key used in, for instance openFd...
Read more >Angular ui-router templates are not loading, Rails backend
it seems that the angular-ui-router is incompatible with the new Rails sprockets. To fix this, add this earlier version of sprockets to your ......
Read more >A Seven-Step Guide to API-First Integration
Be it RESTful APIs or not, APIs act as the gateway to your digital ... integration solution is to know your existing digital...
Read more >Manual: Loading Resources at Runtime
In some situations, it is useful to make an asset available to a project without ... to be supplied in the main game...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have opened a PR at #8103 to incorporate the discussion in this issue.
I don’t think
server.origin
fixes it for me.Hopefully this explains the issue I’m trying to solve:
Example Laravel project structure:
Example Vite config:
Welcome.vue: