Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this PR doing?
This allows any domain to
import()
theclient/index.js
file from https://playground.wordpress.net/.It restores the changes described in:
#873
More specifically, #773 exposed the client library on Playground.wordpress.net:
https://playground.wordpress.net/client/index.js
That PR was accompanied by a .htaccess update to ensure the correct Access-Control-Allow-Origin header was set – otherwise the index.js file cannot be import()-ed in JavaScript.
Unfortunately, that update was lost in a force-push. I patched it ad-hoc on the server, but we should ship the correct setup out of the box.
Luckily, GitHub still keeps that code change here:
a6f685d
What problem is it solving?
Without these changes the
index.js
file cannot beimport()
-ed in JavaScript when pulling the file from a different domain. This adds theset Access-Control-Allow-Origin "*"
header that allow JS running on any domain toimport()
that file.How is the problem addressed?
Other domains aren't able to
import()
theclient/index.js
file from https://playground.wordpress.net/ without CORS headers. Right now, the.htaccess
file has been placed ad-hoc, which is a fragile change that is prone to being lost.This codifies the publishing of the
.htaccess
file as a part of the build process, so it won't be lost or overwritten accidentally.Testing Instructions
Checkout the branch and install deps:
Run the build:
Ensure the following files exist & match the contents below:
dist/packages/playground/remote/.htaccess
dist/packages/playground/website/.htaccess
:dist/packages/playground/wasm-wordpress-net/.htaccess
: