Skip to content

Commit 055eea1

Browse files
committed
Fix CORS proxy for local development
- Remove deprecated curl_close() call (no-op since PHP 8.0, causes deprecation warning in PHP 8.5 that corrupts HTTP response) - Skip POST requests in offline cache (Cache API doesn't support them)
1 parent 8e00815 commit 055eea1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/playground/php-cors-proxy/cors-proxy.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ function(
274274
} else {
275275
@$relay_http_code_and_initial_headers_if_not_already_sent();
276276
}
277-
// Close cURL session
278-
curl_close($ch);
279277

280278
// Only send chunked transfer encoding footer if we're using chunked encoding.
281279
// We need to manually send the footer when running in the PHP built-in server

packages/playground/remote/src/lib/offline-mode-cache.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@ const promisedOfflineModeCache = caches.open(LATEST_CACHE_NAME);
1111

1212
export async function cacheFirstFetch(request: Request): Promise<Response> {
1313
const offlineModeCache = await promisedOfflineModeCache;
14-
const cachedResponse = await offlineModeCache.match(request, {
15-
ignoreSearch: true,
16-
});
17-
if (cachedResponse) {
18-
return cachedResponse;
14+
15+
// The Cache API only supports GET requests
16+
const canCache = request.method === 'GET';
17+
18+
if (canCache) {
19+
const cachedResponse = await offlineModeCache.match(request, {
20+
ignoreSearch: true,
21+
});
22+
if (cachedResponse) {
23+
return cachedResponse;
24+
}
1925
}
2026

2127
/**

0 commit comments

Comments
 (0)