Res.readBytes() doesn't work if the app is not hos...
# compose-web
a
Res.readBytes() doesn't work if the app is not hosted at the root of the domain, does it?
m
No, that can be configured, e.g., in a webmanifest. I use that all the time.
a
how do u do that?
m
Actually that shouldn’t even be necessary. I have a little demo project without a webmanifest and it still works. https://mpmediasoft.de/test/Emmentaler/Emmentaler-Demo-TeaVM-Wasm/ As you can see from the URL this is not located at the root of the domain but it reads a config file via Res.readBytes() https://mpmediasoft.de/test/Emmentaler/Emmentaler-Demo-TeaVM-[…]rdemo.composeapp.generated.resources/files/config.json
I read it like this from the code:
Copy code
@OptIn(ExperimentalResourceApi::class)
    fun configure() {
        runSuspend {
            try {
                val configString = Res.readBytes("files/config.json").decodeToString()
                val config: Config = Json.decodeFromString(configString)
				...
            } catch (e: Exception) {
                log.error(e) { "Could not read configuration resource file." }
            }
        }
    }
a
weird. definatelly not the case here. will investigate when i get the chance
I remember seeing on the console that it was trying to fetch the file from the wrong endpoint
m
I have another project which I have converted to a PWA. In that case I had to configure the root in the webmanifest.
Copy code
"start_url": "./",
"scope": ".",