javascript - Enabling CORS for accessing remote feed - Stack Overflow

I'm trying to read a remote RSS feed and getting the follwing error message:No 'Access-Contro

I'm trying to read a remote RSS feed and getting the follwing error message:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://*.*.*.*' is therefore not allowed access.

Can anyone tell me how to enable CORS so I can resolve this issue - particularly if I don't have admin access to the remote resource?

I'm trying to read a remote RSS feed and getting the follwing error message:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://*.*.*.*' is therefore not allowed access.

Can anyone tell me how to enable CORS so I can resolve this issue - particularly if I don't have admin access to the remote resource?

Share Improve this question asked Feb 9, 2014 at 7:50 siskosisko 9,94020 gold badges74 silver badges142 bronze badges 3
  • What host provider you are using? I think you need to add that header settings into Apache/IIS. – Panu Oksala Commented Feb 9, 2014 at 7:54
  • 1 CORS is a mechanism for the owner of a resource to allow other origins to access it. If you don't own the resource, you can't enable CORS. You can set up a proxy server that fetches the resource and delivers it to the browser on an allowed origin. – apsillers Commented Feb 9, 2014 at 7:57
  • possible duplicate of Access Control Allow Origin not allowed by – Ray Nicholus Commented Feb 9, 2014 at 14:16
Add a ment  | 

2 Answers 2

Reset to default 3

It's up to the remote resource to allow cross-origin resource sharing. The response needs to have a header that specifies that access can e from your domain. Something like:

Access-Control-Allow-Origin: http://xyz.example.

needs to be present in the response headers.

Without control over what the remote site, there's not much you can do to enable CORS to that site (other than contacting the site administrator).

Other CORS headers and how the entire scheme works is described here (among other places).

Seems like a cross domain request issue. Would you consider just using a middle scrit as a proxy workaround? Then make your javascript request to a php file that grabs the data for and feeds it back such as

<?php
$url = 'http://getmethedatafromyourapi';

header('Content-Type:text/json');
echo file_get_contents($url);

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

相关推荐

  • javascript - Enabling CORS for accessing remote feed - Stack Overflow

    I'm trying to read a remote RSS feed and getting the follwing error message:No 'Access-Contro

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信