# How to Fix CORS policy: No 'Access-Control-Allow-Origin' Error

**URL:** <https://forum.kirupa.com/t/how-to-fix-cors-policy-no-access-control-allow-origin-error/642222>\
**Category:** web dev\
**Created:** [March 27, 2020, 2:24am UTC](https://forum.kirupa.com/t/how-to-fix-cors-policy-no-access-control-allow-origin-error/642222 "2020-03-27T02:24:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sukhwinder\_Saini](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Sukhwinder\_Saini](https://forum.kirupa.com/u/Sukhwinder_Saini)\
**Post date:** [March 27, 2020, 2:24am UTC](https://forum.kirupa.com/t/how-to-fix-cors-policy-no-access-control-allow-origin-error/642222/1 "2020-03-27T02:24:26Z")

</div>

i am trying to scrap data from Website name Kijiji but it throws a CORS policy Error i tried using Access-Control-Allow-Origin: \* but it didn’t work out. Here’s my code

```auto
$(document).ready(function () {
 var feeds = ["https://www.kijiji.ca/rss-srp-rideshare-carpool/barrie/rideshare/k0c5l1700006",
        "https://www.kijiji.ca/rss-srp-rideshare-carpool/belleville-area/rideshare/k0c5l1700129",
    ]

    feeds.forEach(feed => $.ajax( feed, {
        accepts: {
            xml: "application/rss+xml",
            Access-Control-Allow-Origin: *
        },
        dataType: "xml",
        success: function (data) {
           console.log(data);
        }
    })); 

```

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [March 27, 2020, 3:25am UTC](https://forum.kirupa.com/t/how-to-fix-cors-policy-no-access-control-allow-origin-error/642222/2 "2020-03-27T03:25:28Z")

</div>

There isn’t a good way around it, for allowing your service to access the data is something the **other** server needs to support. One solution is to use an intermediate server that bypasses CORS along with taking your actual request and returning the right data.

You can see that approach used here: [Checking If A File Exists](http://forum.kirupa.com/t/checking-if-a-file-exists/399354/11)

🙂

---

<div class="post-metadata">

**Author:** ![Sukhwinder\_Saini](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Sukhwinder\_Saini](https://forum.kirupa.com/u/Sukhwinder_Saini)\
**Post date:** [March 27, 2020, 4:35am UTC](https://forum.kirupa.com/t/how-to-fix-cors-policy-no-access-control-allow-origin-error/642222/3 "2020-03-27T04:35:36Z")

</div>

Bro is there any alternative way

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [March 27, 2020, 4:46am UTC](https://forum.kirupa.com/t/how-to-fix-cors-policy-no-access-control-allow-origin-error/642222/4 "2020-03-27T04:46:22Z")

</div>

No. The whole reason CORS exists is to protect sites from having 3rd party/untrusted sources access to their content 🙈

---

<div class="post-metadata">

**Author:** ![Sukhwinder\_Saini](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Sukhwinder\_Saini](https://forum.kirupa.com/u/Sukhwinder_Saini)\
**Post date:** [March 28, 2020, 2:43am UTC](https://forum.kirupa.com/t/how-to-fix-cors-policy-no-access-control-allow-origin-error/642222/5 "2020-03-28T02:43:52Z")

</div>

I found one website which instruct to apply Header on your server in my case i am using Apache how to set header in that

[https://enable-cors.org/server\_apache.html](https://enable-cors.org/server_apache.html)

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [March 28, 2020, 4:52am UTC](https://forum.kirupa.com/t/how-to-fix-cors-policy-no-access-control-allow-origin-error/642222/6 "2020-03-28T04:52:03Z")

</div>

Give it a shot. My guess is that, unless the server you are requesting data from loosens their restrictions, you won’t be successful.
