Skip to content

Commit 1ffe114

Browse files
committed
fix: apps being unable to fetch() anything
Because of `connect-src` CSP Closes #46 Introduced in dd8d072
1 parent db00ae2 commit 1ffe114

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ release date when you use `npm version` (see `README.md`).
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Apps being unable to `fetch()` anything because of `connect-src` CSP
13+
1014
## [0.17.0][] - 2023-06-08
1115

1216
### Added

backend/app.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import type { Info } from "../types/info";
1010
import type { Instance } from "../types/instance";
1111

1212
const SIMULATOR_PATHS = ["/webxdc.js", "/webxdc", "/webxdc/.websocket"];
13-
const CONTENT_SECURITY_POLICY = `default-src 'self';\
13+
const DEFAULT_SRC_VALUES = "'self'";
14+
const CONTENT_SECURITY_POLICY = `default-src ${DEFAULT_SRC_VALUES};\
1415
style-src 'self' 'unsafe-inline' blob: ;\
1516
font-src 'self' data: blob: ;\
1617
script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: ;\
@@ -171,7 +172,9 @@ function getContentSecurityPolicy(
171172
return policy;
172173
}
173174

174-
return policy + `connect-src ${connectSrcUrls.join(" ")} ;`;
175+
return (
176+
policy + `connect-src ${DEFAULT_SRC_VALUES} ${connectSrcUrls.join(" ")} ;`
177+
);
175178
}
176179

177180
function wsUrl(httpUrl: string): string {

0 commit comments

Comments
 (0)