ajax - add access control allow origin in nginx discourse.conf -


so have application on forums.awake-gaming.com , have page on awake-gaming.com post form forums.awake-gaming.com via ajax .

as expected

xmlhttprequest cannot load http://forums.awake-gaming.com/posts. no 'access-control-allow-origin' header present on requested resource. origin 'http://awake-gaming.com' therefore not allowed access. 

so, have access server, added in discourse.conf file under nginx/conf.d directory.

add_header access-control-allow-origin  "http://awake-gaming.com/join-us.html"; add_header access-control-allow-methods: "get, put, post, delete, options"; add_header access-control-allow-headers: "content-type, authorization, x-requested-with"; 

i restarted nginx , tried submit form again, in theory, should work still same error in console :

and ajax call didn't return success either. weird enough, data posted forums.awake-gaming.com , posted(via discourse api).

so went wrong?, tried ask @ meta.discourse.org said problem nginx , not discourse. adding header in .conf file enough ? or need rails well?

i think need specify "http://awake-gaming.com", not "http://awake-gaming.com/join-us.html" access-control-allow-origin value, error message says. actually, if you're using chrome, tell "the 'access-control-allow-origin' whitelists 'http://awake-gaming.com/join-us.html'. origin 'http://awake-gaming.com' not in list, , therefore not allowed access."

on side note, there colons after access-control-allow-methods , access-control-allow-headers, better remove them, don't think they're culprit here.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -