You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have deployed your WordPress install and are having CORS issues be sure to update /wordpress/wp-content/themes/postlight-headless-wp/inc/frontend-origin.php with your frontend origin URL.
However, on a production Linux box, I am still getting CORS errors after updating the theme's "frontend-origin.php" file within the docker container "wordpress", which results in a Connection Timeout. Here are the errors thrown in Chrome.. as Firefox doesn't show this error, but it still occurs..
In dev tools console:
Fetch API cannot load node:net. URL scheme must be "http" or "https" for CORS request.
In browser window:
Error: connect ETIMEDOUT 159.65.79.248:8080 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1138:16)
So... how do we accept 'application/json' requests over CORS in this "wp-headless" app container? I have tried everything I can think of in ".htaccess", but it doesn't follow the set rules. It also seems to totally ignore the rules set in "frontend-origin.php" code action that filters the headers.
Ultimate question now: How do we allow access to the "wp-headless" site via REST API from the "frontend" site if CORS does not support "application/json" header content-type?
Any help is tremendously appreciated!! Thanks.
The text was updated successfully, but these errors were encountered:
Alrighty.. after 7 days of perplexing troubleshooting efforts, the solution for me is to assign a Floating IP address to the DigitalOcean droplet instance (Linux server with Docker). I could not ever get past the CORS error using the internal assigned IP address.. I needed an outside-accessible IP address for everything to pass CORS. I'm not exactly sure why yet, but it works this way. Now I have this project up and running in a production environment on DigitalOcean.
Documentation states:
However, on a production Linux box, I am still getting CORS errors after updating the theme's "frontend-origin.php" file within the docker container "wordpress", which results in a Connection Timeout. Here are the errors thrown in Chrome.. as Firefox doesn't show this error, but it still occurs..
In dev tools console:
In browser window:
UPDATES/HINTS:
I have a strong feeling that it is because the "wp-headless" app exposes the root at 8080 as the WordPress API, meaning it serves up http://ip-address-or-domain:8080/wp-json/, which is of content-type 'application/json', which is NOT supported by CORS (see Mozilla article: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS for this and other good info).
So... how do we accept 'application/json' requests over CORS in this "wp-headless" app container? I have tried everything I can think of in ".htaccess", but it doesn't follow the set rules. It also seems to totally ignore the rules set in "frontend-origin.php" code action that filters the headers.
Ultimate question now: How do we allow access to the "wp-headless" site via REST API from the "frontend" site if CORS does not support "application/json" header content-type?
Any help is tremendously appreciated!! Thanks.
The text was updated successfully, but these errors were encountered: