Curl error connecting local Discourse and WordPress sites

For the past while I’ve been getting the following error when attempting to connect my local Discourse and WordPress sites:

cURL error 61: Unrecognized content encoding type. libcurl understands deflate, gzip, br content encodings.

The issue seems to be that in a local dev environment, Discourse is setting the following header:

content-encoding: null

My local Apache server is unable to handle the content-encoding: null header. From my wp shell, a request to wp_remote_get("http://localhost:4200/site.json") fails with the error I posted above, while a request to a Discourse production site, for example wp_remote_get("https://meta.discourse.org/site.json") works without any issues.

My temporary workaround for the issue is to comment out this line on my local Discourse install: discourse/index.js at main · discourse/discourse · GitHub. That’s not a great solution though. Has anyone run into similar issues with connecting to a Discourse site running on localhost? Does anyone have suggestions for how to configure a local Apache server to accept responses that have the content-encoding: null header?

I wish I knew exactly when the issue started. Possibly it’s been occurring since Discourse started setting the content-encoding: null header.

Edit: the issue is happening on Ubuntu 22.04.1. Curl version: curl 7.81.0. PHP version: 8.1.2. This isn’t at all urgent, but I’m curious about what’s going on.

2 Likes

Interesting! This rings a faint bell that I can’t quite place at the moment. But I guess my first question is where and why is Discourse setting the content-encoding header to null?

This does indeed seem to be a “development-only” issue. This looks related

1 Like