-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Playground could not serve the request. #1349
Comments
The message comes from this catch code. How can I recreate this error using your plugin? |
I assume that these are CORS preflight requests.
Do you see any CORS errors in the browser console when this request is made? If I understood correctly your plugin is making requests to a server. Does this server have CORS enabled? |
Sure, look here: https://plugins.svn.wordpress.org/easy-language/assets/blueprints/blueprint.json
Yes, I see an error message there relating to CORS. But only in the Playground - it doesn't occur in a normal WordPress installation. |
That's expected. If a server requests files from an endpoint, CORS permissions don't apply to it. I edited the blueprint you shared to include your plugin:
When I run it on Playground |
First of all, thank you for your support and for your questions. The CORS messages that you see immediately after setup are actually not my problem. Once the Playground is loaded, go to "Seiten" (ala Pages) and click on one of the "+" icons in the table. In the dialog that opens, click on the blue "Simplify now with..." button. At that moment, a request is triggered via AJAX and sent to my proxy (external URL starting with EDIT: Incidentally, the request is sent via wp_safe_remote_post(). |
This looks like a CORS issue to me. I verified your domain You can also test this by executing a fetch request in your browser console To resolve this you will need to add CORS support to your server, or create a proxy server that supports CORS and route your requests through it if you can't modify CORS headers on your API server. I'm closing this issue as it doesn't seem like there is anything we can do in Playground, but please feel free to keep commenting here, I'm happy to help. |
Thank you for your support. I think this issue will also help others who are facing exactly the same challenge. By the way, I only had to add the following on my server before every other issue to solve this:
|
Linking to #772 as variations of this issue come up frequently. We should find a way of telling the developer what went wrong, it could even be an mu-plugin that overrides window.fetch with a version that logs an extra error message discussing CORS. Ideally, every popular gotcha would log a clear message providing a clear way forward without going through GitHub issues. @bgrgicak would you please start a new high-priority issue to track that? FYI @brandonpayton |
Hi,
I am currently testing whether my plugin https://wordpress.org/plugins/easy-language/ can be used for the preview. The plugin establishes an HTTP connection for a translation of texts in the website to a PHP script I developed for this purpose, which serves as a proxy for the actual API-interface. The request is sent thanks to the activated network feature, but I always get an error message back.
The request arrives at my PHP script like this:
[30/Apr/2024:17:04:11 +0200] “OPTIONS /directory/index.php HTTP/2.0” 404 1 “https://playground.wordpress.net/” “Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0”
which is strange, as I am actually sending a POST request.
As an error message I get this message in the plugin: “Playground could not serve the request.” with HTTP status 400.
Where does this message come from? And why is an OPTIONS request being sent here instead of the actual POST?
Thanks for any feedback :-)
The text was updated successfully, but these errors were encountered: