Skip to content

Conversation

@akirk
Copy link
Member

@akirk akirk commented Jan 22, 2026

Motivation for the change, related issues

When running npm run dev with PHP 8.5, the Vite dev server logs errors like:

[vite] http proxy error: /cors-proxy.php?https://api.wordpress.org/plugins/update-check/1.1/
Error: Parse Error: Invalid character in chunk size

This happens because curl_close() is deprecated since PHP 8.5 and outputs a deprecation warning that corrupts the HTTP response body.

Additionally, the service worker's offline cache was throwing errors for POST requests because the Cache API doesn't support them.

Implementation details

CORS proxy fix:

  • Remove the deprecated curl_close() call - it has no effect since PHP 8.0 anyway

Offline cache fix:

  • Skip caching for non-GET requests (Cache API only supports GET)

Testing Instructions

  1. Run npm run dev
  2. Open the Playground in the browser
  3. Verify no more "Parse Error: Invalid character in chunk size" errors in the terminal
  4. Verify no "Failed to execute 'put' on 'Cache': Request method 'POST' is unsupported" errors in the console

@akirk akirk force-pushed the fix/cors-proxy-chunked-encoding branch 3 times, most recently from 4b8fcb7 to f032ee9 Compare January 22, 2026 17:10
Copy link
Collaborator

@adamziel adamziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand what this PR does, I've left some notes inline.

@akirk akirk marked this pull request as draft January 22, 2026 18:45
@akirk
Copy link
Member Author

akirk commented Jan 22, 2026

Sorry, this wasn't ready yet. I was fighting with the local cors proxy to work with git.

@akirk akirk force-pushed the fix/cors-proxy-chunked-encoding branch from 281acce to 39533bf Compare January 22, 2026 18:55
- Don't pass through Transfer-Encoding header (curl decodes chunked responses)
- Don't pass through Connection header (proxy manages its own connection)
- Simplify send_response_chunk (no manual chunking needed)
- Skip POST requests in offline cache (Cache API doesn't support them)
- Suppress PHP deprecation warnings to avoid polluting response body
- Fix undefined CONTENT_LENGTH array access
@akirk akirk force-pushed the fix/cors-proxy-chunked-encoding branch from 39533bf to 258d8c1 Compare January 22, 2026 18:59
@akirk
Copy link
Member Author

akirk commented Jan 22, 2026

I realized the problem was PHP8.5 and the error reporting that polluted the output.

[Thu Jan 22 16:20:35 2026] PHP Deprecated:  Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /Users/alex/Sites/wordpress-playground/packages/playground/php-cors-proxy/cors-proxy.php on line 278

- 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)
@akirk akirk changed the title Fix CORS proxy chunked encoding causing Vite proxy errors Fix CORS proxy for local development Jan 22, 2026
@akirk akirk changed the title Fix CORS proxy for local development Fix CORS proxy for local development and PHP 8.5 Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants