From c93b589255ed351dd0ff5623a128007afdef36f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Tue, 15 Oct 2024 18:01:54 +0100 Subject: [PATCH] Blueprints: Use `?` instead of `/` to CORS Proxy URLs 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. --- packages/playground/blueprints/src/lib/compile.ts | 2 +- packages/playground/blueprints/src/lib/resources.ts | 2 +- packages/playground/client/src/index.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/playground/blueprints/src/lib/compile.ts b/packages/playground/blueprints/src/lib/compile.ts index 4a45c3391d..30c31a9cbd 100644 --- a/packages/playground/blueprints/src/lib/compile.ts +++ b/packages/playground/blueprints/src/lib/compile.ts @@ -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; } diff --git a/packages/playground/blueprints/src/lib/resources.ts b/packages/playground/blueprints/src/lib/resources.ts index 67776ad75a..e9524aa21a 100644 --- a/packages/playground/blueprints/src/lib/resources.ts +++ b/packages/playground/blueprints/src/lib/resources.ts @@ -459,7 +459,7 @@ export class GitDirectoryResource extends Resource { 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' diff --git a/packages/playground/client/src/index.ts b/packages/playground/client/src/index.ts index 43dcf55853..7e7a891f43 100644 --- a/packages/playground/client/src/index.ts +++ b/packages/playground/client/src/index.ts @@ -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