WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.63k stars 248 forks source link

HTTP POST request to rest endpoint returning Host is unreachable #1403

Open eherman-godaddy opened 4 months ago

eherman-godaddy commented 4 months ago

I am trying to send a POST request to a rest endpoint I have running in a playground instance. However, the request is returning PHP Request Startup: Unable to connect to ssl://playground.wordpress.net:443 (Host is unreachable). I have networking enabled in the features.

I'm essentially just running this via runPHP with the JS API:

<?php 
require_once 'wordpress/wp-load.php';
$post = wp_remote_post( get_rest_url( null, '/custom-endpoint/v1/test' ) );

The rest URL does contain the scope

https://playground.wordpress.net/scope:0.2650545321128708/wp-json/custom-endpoint/v1/test

Returns:

PHP Request Startup: Unable to connect to ssl://playground.wordpress.net:443 (Host is unreachable)

Is this not possible or is there another way that I've missed?

brandonpayton commented 4 months ago

Hi @eherman-godaddy,

This reminds me of #1203 and #1365 which have to do with when Playground handles a request with PHP.

In addition, we just updated DNS to point playground.wordpress.net to a better hosting setup this morning. Perhaps there's something there causing an issue? The old DNS entries had something like a 4 hour TTL. I wonder if clearing DNS cache might have any affect on whether Playground is able to give you a 404 for that path.

Either way, based on my understanding the above issues, I wouldn't guess the custom endpoint request would work today, though I could be wrong.

eherman-godaddy commented 4 months ago

@brandonpayton Thanks for the quick reply. I'll see if I can find a work around for now, for my needs. Just one more question - when I install the Health Check plugin it says that the cURL module has been disabled. I don't think that was the case previously. Was that recently disabled?

image

Edit: I think I found my answer here: https://github.com/WordPress/wordpress-playground/pull/1093

brandonpayton commented 4 months ago

Regarding the original issue, I believe it should be naturally resolved as part of #1203.

As an experiment, you might try adding a ".php" suffix to your custom endpoint name to see whether you are able to access that.

I think I found my answer here: https://github.com/WordPress/wordpress-playground/pull/1093

^ Yep. Unfortunately, Playground on the web does not yet support curl.