Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file. Take a look

**Warning:** Features marked as *experimental* may change or be removed in a future release without notice. Use with caution.

<!-- ## [Unreleased] -->
## [Unreleased]

### Fixed

#### Navigator

* Fixed usage of assets, including fonts in publication resources.

## [3.2.0] - 2026-05-13

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ internal class WebViewServer(
if (isServedAsset(path.removePrefix("/"))) {
// Request is for a known asset.
assetsLoader.shouldInterceptRequest(request.url)
?.apply { allowCors() }
} else {
val error = ReadError.Decoding(
"Attempted to load an unknown asset from $requestUrl"
Expand Down Expand Up @@ -253,6 +254,15 @@ internal class WebViewServer(
}
}

/**
* Allow the response to be consumed by publication documents served
* from any origin, including the package domain.
*/
private fun WebResourceResponse.allowCors() {
responseHeaders = responseHeaders ?: mutableMapOf()
responseHeaders["Access-Control-Allow-Origin"] = "*"
}

private fun serveErrorResponse(): WebResourceResponse {
return serveResource(errorResource(), null, MediaType.XHTML)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public class WebViewServer(
if (isServedAsset(path.removePrefix("/"))) {
// Request is for a known asset.
assetsLoader.shouldInterceptRequest(request.url)
?.apply { allowCors() }
} else {
val error = ReadError.Decoding(
"Attempted to load an unknown asset from $requestUrl"
Expand Down Expand Up @@ -219,6 +220,15 @@ public class WebViewServer(
}
}

/**
* Allow the response to be consumed by publication documents served
* from any origin, including the package domain.
*/
private fun WebResourceResponse.allowCors() {
responseHeaders = responseHeaders ?: mutableMapOf()
responseHeaders["Access-Control-Allow-Origin"] = "*"
}

private fun errorResource(): Resource =
StringResource {
withContext(Dispatchers.IO) {
Expand Down
Loading