Skip to content

Commit 8cd38a5

Browse files
[Remote] Use CORS proxy in embedded Playgrounds (#2369)
Playground does not use the CORS proxy when its embedded on another site via an iframe. This PR changes that and defaults to using CORS proxy also in embeds. Follows-up on #2368 ## Testing instructions - CI - Test CORS requests within Playground block after deployment --------- Co-authored-by: Brandon Payton <[email protected]>
1 parent e0b8815 commit 8cd38a5

File tree

11 files changed

+160
-137
lines changed

11 files changed

+160
-137
lines changed

CHANGELOG.md

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,71 @@ All notable changes to this project are documented in this file by a CI job
44
that runs on every NPM release. The file follows the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
55
format.
66

7-
## [v1.2.3] (2025-07-21)
7+
## [v1.2.3] (2025-07-21)
88

99
### Enhancements
1010

11-
- [Playground CLI] Consolidate auto mounting logic. ([#2360](https://github.com/WordPress/wordpress-playground/pull/2360))
12-
- [Playground CLI] Move mounting code to mount.ts. ([#2362](https://github.com/WordPress/wordpress-playground/pull/2362))
11+
- [Playground CLI] Consolidate auto mounting logic. ([#2360](https://github.com/WordPress/wordpress-playground/pull/2360))
12+
- [Playground CLI] Move mounting code to mount.ts. ([#2362](https://github.com/WordPress/wordpress-playground/pull/2362))
1313

1414
### Blueprints
1515

16-
- [CLI] Move Blueprints v2 to Playground CLI package. ([#2364](https://github.com/WordPress/wordpress-playground/pull/2364))
16+
- [CLI] Move Blueprints v2 to Playground CLI package. ([#2364](https://github.com/WordPress/wordpress-playground/pull/2364))
1717

1818
### Public API
1919

20-
2120
#### Blueprints
2221

23-
- [Client] Accept wasm.wordpress.net as an official origin. ([#2368](https://github.com/WordPress/wordpress-playground/pull/2368))
22+
- [Client] Accept wasm.wordpress.net as an official origin. ([#2368](https://github.com/WordPress/wordpress-playground/pull/2368))
2423

2524
### Tools
2625

27-
- Make PHP 8.3 the default version. ([#2371](https://github.com/WordPress/wordpress-playground/pull/2371))
26+
- Make PHP 8.3 the default version. ([#2371](https://github.com/WordPress/wordpress-playground/pull/2371))
2827

2928
#### PHP WebAssembly
3029

31-
- Add `--xdebug` option in php-wasm CLI and wp-playground CLI. ([#2346](https://github.com/WordPress/wordpress-playground/pull/2346))
30+
- Add `--xdebug` option in php-wasm CLI and wp-playground CLI. ([#2346](https://github.com/WordPress/wordpress-playground/pull/2346))
3231

3332
### Documentation
3433

35-
- Adding Playground CLI page and removing wp-now references. ([#2337](https://github.com/WordPress/wordpress-playground/pull/2337))
36-
- Adding pt-br About and Launch Page. ([#2358](https://github.com/WordPress/wordpress-playground/pull/2358))
37-
- Adding three new flags on the CLI README file. ([#2325](https://github.com/WordPress/wordpress-playground/pull/2325))
38-
- Adding video content in Japanese to resources page. ([#2354](https://github.com/WordPress/wordpress-playground/pull/2354))
39-
- Updating web instance page documentation. ([#2365](https://github.com/WordPress/wordpress-playground/pull/2365))
34+
- Adding Playground CLI page and removing wp-now references. ([#2337](https://github.com/WordPress/wordpress-playground/pull/2337))
35+
- Adding pt-br About and Launch Page. ([#2358](https://github.com/WordPress/wordpress-playground/pull/2358))
36+
- Adding three new flags on the CLI README file. ([#2325](https://github.com/WordPress/wordpress-playground/pull/2325))
37+
- Adding video content in Japanese to resources page. ([#2354](https://github.com/WordPress/wordpress-playground/pull/2354))
38+
- Updating web instance page documentation. ([#2365](https://github.com/WordPress/wordpress-playground/pull/2365))
4039

4140
### PHP WebAssembly
4241

43-
- [PHP-wasm Node] Remove unused node creation code from createNodeFsMountHandler. ([#2379](https://github.com/WordPress/wordpress-playground/pull/2379))
44-
- [PHP-wasm] File mounting in NODEFS. ([#2338](https://github.com/WordPress/wordpress-playground/pull/2338))
45-
- [PHP] Improve error logging. ([#2357](https://github.com/WordPress/wordpress-playground/pull/2357))
46-
- [PHP] Isomorphic, reusable spawn handler. ([#2359](https://github.com/WordPress/wordpress-playground/pull/2359))
47-
- [PHP] Refresh the latest PHP versions before recompiling. ([#2372](https://github.com/WordPress/wordpress-playground/pull/2372))
48-
- [php-wasm/universal] Try require() before dynamic imprt in comlink-sync.ts. ([#2363](https://github.com/WordPress/wordpress-playground/pull/2363))
42+
- [PHP-wasm Node] Remove unused node creation code from createNodeFsMountHandler. ([#2379](https://github.com/WordPress/wordpress-playground/pull/2379))
43+
- [PHP-wasm] File mounting in NODEFS. ([#2338](https://github.com/WordPress/wordpress-playground/pull/2338))
44+
- [PHP] Improve error logging. ([#2357](https://github.com/WordPress/wordpress-playground/pull/2357))
45+
- [PHP] Isomorphic, reusable spawn handler. ([#2359](https://github.com/WordPress/wordpress-playground/pull/2359))
46+
- [PHP] Refresh the latest PHP versions before recompiling. ([#2372](https://github.com/WordPress/wordpress-playground/pull/2372))
47+
- [php-wasm/universal] Try require() before dynamic imprt in comlink-sync.ts. ([#2363](https://github.com/WordPress/wordpress-playground/pull/2363))
4948

5049
### Website
5150

52-
- Deploy public web app after WP major/beta update. ([#2378](https://github.com/WordPress/wordpress-playground/pull/2378))
51+
- Deploy public web app after WP major/beta update. ([#2378](https://github.com/WordPress/wordpress-playground/pull/2378))
5352

5453
### Bug Fixes
5554

56-
- Allow the WP update and changelog workflows to commit to trunk again. ([#2377](https://github.com/WordPress/wordpress-playground/pull/2377))
57-
- Fix failing WP update workflows. ([#2376](https://github.com/WordPress/wordpress-playground/pull/2376))
55+
- Allow the WP update and changelog workflows to commit to trunk again. ([#2377](https://github.com/WordPress/wordpress-playground/pull/2377))
56+
- Fix failing WP update workflows. ([#2376](https://github.com/WordPress/wordpress-playground/pull/2376))
5857

5958
### Various
6059

61-
- Add Japanese translations to Resources References. ([#2352](https://github.com/WordPress/wordpress-playground/pull/2352))
62-
- Add new logo and open graph image. ([#2350](https://github.com/WordPress/wordpress-playground/pull/2350))
63-
- Adding Portuguese version for Code Standards, Code, and Documentation.. ([#2343](https://github.com/WordPress/wordpress-playground/pull/2343))
64-
- Adding new icons and og:Image for the Playground Web instance. ([#2367](https://github.com/WordPress/wordpress-playground/pull/2367))
65-
- Update Japanese translations to main directory. ([#2375](https://github.com/WordPress/wordpress-playground/pull/2375))
60+
- Add Japanese translations to Resources References. ([#2352](https://github.com/WordPress/wordpress-playground/pull/2352))
61+
- Add new logo and open graph image. ([#2350](https://github.com/WordPress/wordpress-playground/pull/2350))
62+
- Adding Portuguese version for Code Standards, Code, and Documentation.. ([#2343](https://github.com/WordPress/wordpress-playground/pull/2343))
63+
- Adding new icons and og:Image for the Playground Web instance. ([#2367](https://github.com/WordPress/wordpress-playground/pull/2367))
64+
- Update Japanese translations to main directory. ([#2375](https://github.com/WordPress/wordpress-playground/pull/2375))
6665

6766
### Contributors
6867

6968
The following contributors merged PRs in this release:
7069

7170
@adamziel @bgrgicak @brandonpayton @fellyph @mho22 @shimotmk
7271

73-
7472
## [v1.2.2] (2025-07-14)
7573

7674
### Enhancements

packages/docs/site/docs/main/changelog.md

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,73 +9,71 @@ All notable changes to this project are documented in this file by a CI job
99
that runs on every NPM release. The file follows the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
1010
format.
1111

12-
## [v1.2.3] (2025-07-21)
12+
## [v1.2.3] (2025-07-21)
1313

1414
### Enhancements
1515

16-
- [Playground CLI] Consolidate auto mounting logic. ([#2360](https://github.com/WordPress/wordpress-playground/pull/2360))
17-
- [Playground CLI] Move mounting code to mount.ts. ([#2362](https://github.com/WordPress/wordpress-playground/pull/2362))
16+
- [Playground CLI] Consolidate auto mounting logic. ([#2360](https://github.com/WordPress/wordpress-playground/pull/2360))
17+
- [Playground CLI] Move mounting code to mount.ts. ([#2362](https://github.com/WordPress/wordpress-playground/pull/2362))
1818

1919
### Blueprints
2020

21-
- [CLI] Move Blueprints v2 to Playground CLI package. ([#2364](https://github.com/WordPress/wordpress-playground/pull/2364))
21+
- [CLI] Move Blueprints v2 to Playground CLI package. ([#2364](https://github.com/WordPress/wordpress-playground/pull/2364))
2222

2323
### Public API
2424

25-
2625
#### Blueprints
2726

28-
- [Client] Accept wasm.wordpress.net as an official origin. ([#2368](https://github.com/WordPress/wordpress-playground/pull/2368))
27+
- [Client] Accept wasm.wordpress.net as an official origin. ([#2368](https://github.com/WordPress/wordpress-playground/pull/2368))
2928

3029
### Tools
3130

32-
- Make PHP 8.3 the default version. ([#2371](https://github.com/WordPress/wordpress-playground/pull/2371))
31+
- Make PHP 8.3 the default version. ([#2371](https://github.com/WordPress/wordpress-playground/pull/2371))
3332

3433
#### PHP WebAssembly
3534

36-
- Add `--xdebug` option in php-wasm CLI and wp-playground CLI. ([#2346](https://github.com/WordPress/wordpress-playground/pull/2346))
35+
- Add `--xdebug` option in php-wasm CLI and wp-playground CLI. ([#2346](https://github.com/WordPress/wordpress-playground/pull/2346))
3736

3837
### Documentation
3938

40-
- Adding Playground CLI page and removing wp-now references. ([#2337](https://github.com/WordPress/wordpress-playground/pull/2337))
41-
- Adding pt-br About and Launch Page. ([#2358](https://github.com/WordPress/wordpress-playground/pull/2358))
42-
- Adding three new flags on the CLI README file. ([#2325](https://github.com/WordPress/wordpress-playground/pull/2325))
43-
- Adding video content in Japanese to resources page. ([#2354](https://github.com/WordPress/wordpress-playground/pull/2354))
44-
- Updating web instance page documentation. ([#2365](https://github.com/WordPress/wordpress-playground/pull/2365))
39+
- Adding Playground CLI page and removing wp-now references. ([#2337](https://github.com/WordPress/wordpress-playground/pull/2337))
40+
- Adding pt-br About and Launch Page. ([#2358](https://github.com/WordPress/wordpress-playground/pull/2358))
41+
- Adding three new flags on the CLI README file. ([#2325](https://github.com/WordPress/wordpress-playground/pull/2325))
42+
- Adding video content in Japanese to resources page. ([#2354](https://github.com/WordPress/wordpress-playground/pull/2354))
43+
- Updating web instance page documentation. ([#2365](https://github.com/WordPress/wordpress-playground/pull/2365))
4544

4645
### PHP WebAssembly
4746

48-
- [PHP-wasm Node] Remove unused node creation code from createNodeFsMountHandler. ([#2379](https://github.com/WordPress/wordpress-playground/pull/2379))
49-
- [PHP-wasm] File mounting in NODEFS. ([#2338](https://github.com/WordPress/wordpress-playground/pull/2338))
50-
- [PHP] Improve error logging. ([#2357](https://github.com/WordPress/wordpress-playground/pull/2357))
51-
- [PHP] Isomorphic, reusable spawn handler. ([#2359](https://github.com/WordPress/wordpress-playground/pull/2359))
52-
- [PHP] Refresh the latest PHP versions before recompiling. ([#2372](https://github.com/WordPress/wordpress-playground/pull/2372))
53-
- [php-wasm/universal] Try require() before dynamic imprt in comlink-sync.ts. ([#2363](https://github.com/WordPress/wordpress-playground/pull/2363))
47+
- [PHP-wasm Node] Remove unused node creation code from createNodeFsMountHandler. ([#2379](https://github.com/WordPress/wordpress-playground/pull/2379))
48+
- [PHP-wasm] File mounting in NODEFS. ([#2338](https://github.com/WordPress/wordpress-playground/pull/2338))
49+
- [PHP] Improve error logging. ([#2357](https://github.com/WordPress/wordpress-playground/pull/2357))
50+
- [PHP] Isomorphic, reusable spawn handler. ([#2359](https://github.com/WordPress/wordpress-playground/pull/2359))
51+
- [PHP] Refresh the latest PHP versions before recompiling. ([#2372](https://github.com/WordPress/wordpress-playground/pull/2372))
52+
- [php-wasm/universal] Try require() before dynamic imprt in comlink-sync.ts. ([#2363](https://github.com/WordPress/wordpress-playground/pull/2363))
5453

5554
### Website
5655

57-
- Deploy public web app after WP major/beta update. ([#2378](https://github.com/WordPress/wordpress-playground/pull/2378))
56+
- Deploy public web app after WP major/beta update. ([#2378](https://github.com/WordPress/wordpress-playground/pull/2378))
5857

5958
### Bug Fixes
6059

61-
- Allow the WP update and changelog workflows to commit to trunk again. ([#2377](https://github.com/WordPress/wordpress-playground/pull/2377))
62-
- Fix failing WP update workflows. ([#2376](https://github.com/WordPress/wordpress-playground/pull/2376))
60+
- Allow the WP update and changelog workflows to commit to trunk again. ([#2377](https://github.com/WordPress/wordpress-playground/pull/2377))
61+
- Fix failing WP update workflows. ([#2376](https://github.com/WordPress/wordpress-playground/pull/2376))
6362

6463
### Various
6564

66-
- Add Japanese translations to Resources References. ([#2352](https://github.com/WordPress/wordpress-playground/pull/2352))
67-
- Add new logo and open graph image. ([#2350](https://github.com/WordPress/wordpress-playground/pull/2350))
68-
- Adding Portuguese version for Code Standards, Code, and Documentation.. ([#2343](https://github.com/WordPress/wordpress-playground/pull/2343))
69-
- Adding new icons and og:Image for the Playground Web instance. ([#2367](https://github.com/WordPress/wordpress-playground/pull/2367))
70-
- Update Japanese translations to main directory. ([#2375](https://github.com/WordPress/wordpress-playground/pull/2375))
65+
- Add Japanese translations to Resources References. ([#2352](https://github.com/WordPress/wordpress-playground/pull/2352))
66+
- Add new logo and open graph image. ([#2350](https://github.com/WordPress/wordpress-playground/pull/2350))
67+
- Adding Portuguese version for Code Standards, Code, and Documentation.. ([#2343](https://github.com/WordPress/wordpress-playground/pull/2343))
68+
- Adding new icons and og:Image for the Playground Web instance. ([#2367](https://github.com/WordPress/wordpress-playground/pull/2367))
69+
- Update Japanese translations to main directory. ([#2375](https://github.com/WordPress/wordpress-playground/pull/2375))
7170

7271
### Contributors
7372

7473
The following contributors merged PRs in this release:
7574

7675
@adamziel @bgrgicak @brandonpayton @fellyph @mho22 @shimotmk
7776

78-
7977
## [v1.2.2] (2025-07-14)
8078

8179
### Enhancements

packages/php-wasm/xdebug-bridge/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
"rules": {}
1616
}
1717
]
18-
}
18+
}

packages/php-wasm/xdebug-bridge/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ await server.start();
2121

2222
// Start with custom configuration
2323
const server = startXDebugBridge({
24-
protocol: 'cdp', // or 'dap'
25-
xdebugServerPort: 9003, // XDebug connection port
26-
xdebugServerHost: 'localhost',
27-
verbose: false, // Silent mode
24+
protocol: 'cdp', // or 'dap'
25+
xdebugServerPort: 9003, // XDebug connection port
26+
xdebugServerHost: 'localhost',
27+
verbose: false, // Silent mode
2828
});
2929

3030
await server.start();
@@ -51,20 +51,20 @@ npx xdebug-bridge --help
5151

5252
## Configuration Options
5353

54-
- `protocol`: Protocol to use ('cdp' or 'dap', default: 'cdp')
55-
- `xdebugServerPort`: Port to listen for XDebug connections (default: 9003)
56-
- `xdebugServerHost`: Host to bind to (default: 'localhost')
57-
- `verbose`: Enable verbose logging (default: false for API, true for CLI)
58-
- `logger`: Custom logger function
54+
- `protocol`: Protocol to use ('cdp' or 'dap', default: 'cdp')
55+
- `xdebugServerPort`: Port to listen for XDebug connections (default: 9003)
56+
- `xdebugServerHost`: Host to bind to (default: 'localhost')
57+
- `verbose`: Enable verbose logging (default: false for API, true for CLI)
58+
- `logger`: Custom logger function
5959

6060
## Events
6161

6262
The server emits events for monitoring connection activity:
6363

64-
- `started`: Server has started
65-
- `stopped`: Server has stopped
66-
- `connection`: New XDebug connection established
67-
- `disconnection`: XDebug connection closed
68-
- `xdebugData`: Raw XDebug data received
69-
- `error`: Server error occurred
70-
- `socketError`: Socket-level error occurred
64+
- `started`: Server has started
65+
- `stopped`: Server has stopped
66+
- `connection`: New XDebug connection established
67+
- `disconnection`: XDebug connection closed
68+
- `xdebugData`: Raw XDebug data received
69+
- `error`: Server error occurred
70+
- `socketError`: Socket-level error occurred

packages/php-wasm/xdebug-bridge/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
"node": ">=20.18.3",
4545
"npm": ">=10.1.0"
4646
}
47-
}
47+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './xdebug-bridge';
1+
export * from './xdebug-bridge';

packages/php-wasm/xdebug-bridge/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"path": "./tsconfig.spec.json"
1919
}
2020
]
21-
}
21+
}

packages/php-wasm/xdebug-bridge/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
},
88
"include": ["src/**/*.ts"],
99
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
10-
}
10+
}

packages/php-wasm/xdebug-bridge/tsconfig.spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
"src/**/*.spec.ts",
1212
"src/**/*.d.ts"
1313
]
14-
}
14+
}

packages/playground/remote/src/lib/worker-thread.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ import {
5959
networkingDisabledFunctions,
6060
} from './disabled-functions';
6161
import { WordPressFetchNetworkTransport } from './wordpress-fetch-network-transport';
62+
/* @ts-ignore */
63+
import { corsProxyUrl as defaultCorsProxyUrl } from 'virtual:cors-proxy-url';
6264

6365
// post message to parent
6466
self.postMessage('worker-script-started');
@@ -189,6 +191,10 @@ export class PlaygroundWorkerEndpoint extends PHPWorker {
189191
throw new Error('Playground already booted');
190192
}
191193

194+
if (corsProxyUrl === undefined) {
195+
corsProxyUrl = defaultCorsProxyUrl;
196+
}
197+
192198
this.booted = true;
193199
this.scope = scope;
194200
this.requestedWordPressVersion = wpVersion;

0 commit comments

Comments
 (0)