在JSON API Wordpress上启用CORS [英] Enable CORS on JSON API Wordpress

查看:386
本文介绍了在JSON API Wordpress上启用CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个wordpress网站与一个插件称为JSON API。这个插件提供了一个JSON格式的内容在wordpress。我能够通过添加标题(Access-Control-Allow-Origin:*)在wordpress上启用CORS;在php头。但是当我尝试的url,JSON API插件提供的CORS不再工作。

I have this wordpress site with a plugin called JSON API. This plugin provides a JSON format for the content that is in the wordpress. I was able to enable CORS on the wordpress by adding header("Access-Control-Allow-Origin: *"); on the php header. But when I tried the url that the JSON API plugin provides the CORS does not work anymore.

这是wordpress网站,我正在做测试...我使用测试cors网站检查它是否是工作,它是...
http://kiwa-app.loading。 net /

This is the wordpress site were I'm doing the tests... I used the test cors website to check if it was working and it is... http://kiwa-app.loading.net/

但是当我尝试使用JSON api提供给我的url时,不再工作了。我仍然有错误No'Access-Control-Allow-Origin'
http:// kiwa- app.loading.net/?json=info

But when I try with the url that the JSON api provides me, is not working anymore. I'm still have the error No 'Access-Control-Allow-Origin' http://kiwa-app.loading.net/?json=info

我会婉言谢谢!!!

推荐答案

Ok我终于找到了一个简单的方法...

Ok I finally figured out an easy way...

你只需要添加:

     <? header("Access-Control-Allow-Origin: *"); ?>

在文件api.php上,此文件位于wp-content / plugins / json-api /singletons/api.php

On the file api.php, this file is located in wp-content/plugins/json-api/singletons/api.php

我希望它能帮助更多同样问题的人!

I hope it helps more people with the same problem!

这篇关于在JSON API Wordpress上启用CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆