load wasm from custom port (#7514)
* load wasm from custom port * Jon's suggestion
This commit is contained in:
@ -9,6 +9,7 @@ VITE_KC_SITE_BASE_URL=https://dev.zoo.dev
|
||||
VITE_KC_SITE_APP_URL=https://app.dev.zoo.dev
|
||||
VITE_KC_SKIP_AUTH=false
|
||||
VITE_KC_CONNECTION_TIMEOUT_MS=5000
|
||||
#VITE_WASM_URL="optional way of overriding the wasm url, particular for unit tests which need this if you running not on the default 3000 port"
|
||||
#VITE_KC_DEV_TOKEN="optional token to skip auth in the app"
|
||||
#token="required token for playwright. TODO: clean up env vars in #3973"
|
||||
|
||||
|
||||
@ -6,6 +6,12 @@ import { webSafeJoin, webSafePathSplit } from '@src/lib/paths'
|
||||
import { init, reloadModule } from '@src/lib/wasm_lib_wrapper'
|
||||
|
||||
export const wasmUrl = () => {
|
||||
const wasmFile = '/kcl_wasm_lib_bg.wasm'
|
||||
// Check for test environment override
|
||||
if (typeof process !== 'undefined' && process.env?.VITE_WASM_URL) {
|
||||
return process.env.VITE_WASM_URL + wasmFile
|
||||
}
|
||||
|
||||
// For when we're in electron (file based) or web server (network based)
|
||||
// For some reason relative paths don't work as expected. Otherwise we would
|
||||
// just do /wasm_lib_bg.wasm. In particular, the issue arises when the path
|
||||
@ -14,8 +20,7 @@ export const wasmUrl = () => {
|
||||
? document.location.origin + '/kcl_wasm_lib_bg.wasm'
|
||||
: document.location.protocol +
|
||||
webSafeJoin(webSafePathSplit(document.location.pathname).slice(0, -1)) +
|
||||
'/kcl_wasm_lib_bg.wasm'
|
||||
|
||||
wasmFile
|
||||
return fullUrl
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user