You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, this is a repeat of #8577. I need to set a base URL with a custom protocol, and Vite doesn't recognize example_no_http://website as an external URL.
(Because the issue is exactly identical, I'm reusing the reproduction example.)
My use case: I am using Tauri and need to serve some assets under a different host than the page which requests them, because I am using a CSP to prohibit scripts loaded from the same domain from running. I therefore cannot use relative URLs for asset loading, and ran into this problem because generally speaking custom protocols are how you serve assets in a Tauri app.
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 vuejs/core instead.
Your 2 method sounds good to try it out. PR welcome, and we can check using ecosystem-ci if things look good. We can then move with it in Vite 5 if others are ok with this change too.
Describe the bug
So, this is a repeat of #8577. I need to set a base URL with a custom protocol, and Vite doesn't recognize
example_no_http://website
as an external URL.(Because the issue is exactly identical, I'm reusing the reproduction example.)
The relevant code in Vite is:
vite/packages/vite/src/node/utils.ts
Lines 266 to 267 in 711dd80
This can be fixed by either:
externalRE
to accept any valid URI protocol.isExternalUrl
to use an existing URL parser (say,url.parse()
in node) and check if there's a protocol provided.My use case: I am using Tauri and need to serve some assets under a different host than the page which requests them, because I am using a CSP to prohibit scripts loaded from the same domain from running. I therefore cannot use relative URLs for asset loading, and ran into this problem because generally speaking custom protocols are how you serve assets in a Tauri app.
(https://docs.rs/tauri/1.4.0/tauri/struct.Builder.html#method.register_uri_scheme_protocol)
Reproduction
https://stackblitz.com/edit/vitejs-vite-bu8uph?file=dist/index.html
Steps to reproduce
pnpm build
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: