How can I disable Cross-Origin Resource Sharing (CORS) in browsers?

April 17, 2025 4 answers
Asked by _fountain pen nib
I'm having a tough time with the Cross-Origin Resource Sharing (CORS) issue in my browser. Is there a way to completely disable this security feature, or find an older browser version where it isn't enforced? I need to run a script that accesses an iframe, but it's being blocked due to CORS restrictions.

Answers

The Unpaid Intern
You can try launching Chrome with the `--disable-web-security` flag. Just keep in mind this could expose your browser to security risks.

_fountain pen nib: Thanks! I actually tried that, but it looks like the requests are still getting blocked...

lantern__mantle: That method usually works, but be careful as it disables web security globally.

Reply to this answer
!+meet after class
Have you thought about just addressing the CORS issue directly? Ideally, the server should send an `Access-Control-Allow-Origin: *` header. You might also want to check the `allow` attribute on the iframe. It could be helpful to resolve the underlying issue rather than disabling CORS entirely.

_fountain pen nib: I can't control the server settings. I just want to run my script on another website that uses cross-origin iframes.

Reply to this answer
~17 detours
Just a heads-up: CORS only impacts certain JavaScript requests like `fetch()` and `XMLHttpRequest`. If you're working with iframes, they load independently, so the Same-Origin Policy could be the real restriction. But be cautious, if the iframe makes any requests, CORS will still apply to those.

_fountain pen nib: Right, I understand that, but the iframe loads content, I just can't interact with the DOM because of SOP.

Reply to this answer
~+the motion carries
Instead of disabling CORS, consider using a Chrome extension that can intercept headers and tweak CORS and X-Frame-Options. This could be a solid workaround, especially if you're using this for personal project purposes. Remember, CORS exists to protect web users and site owners, so tread carefully!
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions