Wednesday, February 27, 2013

Chrome CORS

This is a bit of a follow-up post to my Refused to set unsafe header post. A question I was asked was about how to do something with CORS in Chrome, and my immediate findings were that it is impossible. As of recently I looked back into it and have come across a couple possible solution.

The first possible solution is to make sure to send the proper headers, as Chrome will take into account what the server says is allowed. For this, you can set the access control headers however you want. For the example, I will show the php version I found.

header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true ");
header("Access-Control-Allow-Methods: OPTIONS, GET, POST");
header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control");

This will allow you to set the various headers you would need for a CORS request. Another possibility is by using a content type that the control isn't strictly enforced. With that, it seems by setting the Content-Type to plain/text, it should go through without a problem.

I personally haven't tried either of these because I have yet to have a use for it with what I do, however I wanted to share this bit of information should anyone be curious and happen across here.

No comments:

Post a Comment

Tag Cloud

.NET (2) A+ (5) ad ds (1) addon (4) Android (4) anonymous functions (1) application (9) arduino (1) artificial intelligence (1) backup (1) bash (6) camera (2) certifications (3) comptia (5) css (2) customize (11) encryption (3) error (13) exploit (5) ftp (1) funny (4) gadget (4) games (3) GUI (5) hardware (16) haskell (6) help (14) HTML (3) imaging (2) irc (1) it (1) java (2) javascript (13) jobs (1) Linux (19) lua (1) Mac (4) malware (1) math (6) msp (1) network (13) perl (2) php (3) plugin (2) powershell (8) privacy (2) programming (24) python (10) radio (2) regex (3) repair (2) security (16) sound (2) speakers (2) ssh (1) story (5) Techs from the Crypt (5) telnet (1) tools (13) troubleshooting (11) tutorial (9) Ubuntu (4) Unix (2) virtualization (2) web design (6) Windows (16) world of warcraft (1) wow (1) wx (1)