Skip to content

Commit

Permalink
Blueprints: Use ? instead of / to CORS Proxy URLs (#1899)
Browse files Browse the repository at this point in the history
Makes GitDirectoryResource (introduced in #1858) relay the requests
through `/cors-proxy.php?{url}` instead of `/cors-proxy.php/{url}`. This
makes it compatible with the actual `cors-proxy.php` script Playground
ended up shipping.

 ## Testing instructions

None, this only works in production. Maybe you could run the Blueprint
from #1858 and
confirm in the network tools that it's actually using the `?` instead of
`/`.
  • Loading branch information
adamziel authored Oct 15, 2024
1 parent b1a676d commit 85f8686
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/playground/blueprints/src/lib/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface CompileBlueprintOptions {
*
* For example, if corsProxy is set to "https://cors.wordpress.net/proxy.php",
* then the CORS requests to https://github.com/WordPress/gutenberg.git would actually
* be made to https://cors.wordpress.net/proxy.php/https://github.com/WordPress/gutenberg.git.
* be made to https://cors.wordpress.net/proxy.php?https://github.com/WordPress/gutenberg.git.
*/
corsProxy?: string;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/blueprints/src/lib/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export class GitDirectoryResource extends Resource<Directory> {

async resolve() {
const repoUrl = this.options?.corsProxy
? `${this.options.corsProxy}/${this.reference.url}`
? `${this.options.corsProxy}?${this.reference.url}`
: this.reference.url;
const ref = ['', 'HEAD'].includes(this.reference.ref)
? 'HEAD'
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export interface StartPlaygroundOptions {
*
* For example, if corsProxy is set to "https://cors.wordpress.net/proxy.php",
* then the CORS requests to https://github.com/WordPress/wordpress-playground.git would actually
* be made to https://cors.wordpress.net/proxy.php/https://github.com/WordPress/wordpress-playground.git.
* be made to https://cors.wordpress.net/proxy.php?https://github.com/WordPress/wordpress-playground.git.
*
* The Blueprints library will arbitrarily choose which requests to proxy. If you need
* to proxy every single request, do not use this option. Instead, you should preprocess
Expand Down

0 comments on commit 85f8686

Please sign in to comment.