Cross origin Request

I have installed frappe-js-sdk in my react app which is on localhost:3000 and my backend runs on localhost:8100.

I followed the steps provided in frappe-js-sdk to make API calls

I added allow-cors : “*” in site_config.json file

I’m getting
Access to XMLHttpRequest at ‘http://localhost:8100/api/method/xyz/abc’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Request header field x-frappe-site-name is not allowed by Access-Control-Allow-Headers in preflight response.

Can you please help me out how to address this issue

Replace localhost with the site name.

Can you please elaborate with an example.
I used site name. But it’s still not working.
My site name is siteone. How to use this name?


Add your site to /etc/hosts and point it to your localhost ip

Or use bench instead:

bench --site siteone add-to-hosts

And this:

bench --site siteone set-config ignore_csrf 1

Hope this helps.

1 Like

It’s not working

Can you pls elaborate