rest api - CORS & Remote access to WP via RestAPI

I have built an app which enables the manager of many WP sites to make RestAPI GET, POST, PUT & DELETE requests whic


I have built an app which enables the manager of many WP sites to make RestAPI GET, POST, PUT & DELETE requests which work perfectly when using them from this Apps, when the WP site are hosted on the same domain / subdomains.
I have added the below lines in the .htaccess of the 'remote WP' not hosted on the same domain, in order, I thought, to enable access to the site remotely:

CORS Headers
<ifModule mod_headers.c>
    Header always set Access-Control-Allow-Origin: ""
    Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE"
    Header always set Access-Control-Allow-Headers "X-Requested-With, content-type"
</ifModule>
BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>



I am using Enrique Chavez's JWT -Authentication plugin, and it works great, and would not be in question, and added the CORS Section to the beginning of the htaccess file, to no avail....

Am I missing something ? Am I mistaken on the role and capabilities of CORS authorizations (...) w/ regards to accessing a remote DB (my primary request to the WP site is in fact a request to the remote DB not hosted on the same domain as the app , and fails with the below message:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Which indicates a failure to access the remote database...Is this in any way related to any possible CORS bypass / is the htaccess config to "blame" ?

Many thanks for your help

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744826541a4595831.html

相关推荐

  • rest api - CORS &amp; Remote access to WP via RestAPI

    I have built an app which enables the manager of many WP sites to make RestAPI GET, POST, PUT & DELETE requests whic

    2天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信