Enable CORS on JSON API Wordpress

前端 未结 10 2087
南笙
南笙 2020-12-03 03:28

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 wordp

10条回答
  •  时光取名叫无心
    2020-12-03 03:52

    In WordPress project go to following file and do like this:

    In wp-includes/rest-api.php change:

    header( 'Access-Control-Allow-Origin: ' . $origin );
    

    to:

    header( 'Access-Control-Allow-Origin: *' );
    

    In wp-includes/http.php change:

    header( 'Access-Control-Allow-Origin: ' . $origin );
    

    to:

    header( 'Access-Control-Allow-Origin: *' );
    

提交回复
热议问题