New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"WARNING:tornado.access:405 OPTIONS" error will not allow POST #2104
Comments
This has something to do with preflight of OPTIONS |
This is a security measure that is working as intended. If you have a POST handler that you wish to make available cross-origin (and you understand the security implications of doing so), you must implement |
Leaving this here so people have a link to the tornado API for RequestHandler.options() http://www.tornadoweb.org/en/stable/web.html#tornado.web.RequestHandler.options Also, a link to the SO that helped me solve my problem: |
@bdarnell I am sorry i have to write this but you deserve a fucking yell from thousands of developers. |
I spent two hours,my solution,my code.
|
def initialize(self): self.set_default_header() def set_default_header(self): self.set_header('Access-Control-Allow-Origin', '*') self.set_header('Access-Control-Allow-Headers', '*') self.set_header('Access-Control-Max-Age', 1000) self.set_header('Content-type', 'application/json') self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') self.set_header('Access-Control-Allow-Headers', 'Content-Type, Access-Control-Allow-Origin, Access-Control-Allow-Headers, X-Requested-By, Access-Control-Allow-Methods')
Testing with js, if I use an ajax call with "GET," it receives what it should. If I change it to "POST" an error is thrown on both client and server side.
The server side error is as follows
WARNING:tornado.access:405 OPTIONS / (127.0.0.1) 2.12ms
I have tried running the ajax call both from
file://index.html
andlocalhost:8000/index.html
with the same result in both cases.The text was updated successfully, but these errors were encountered: