Add a default OPTIONS handler for wsgi (#2301)
When a browser makes a CORS request, it often makes a 'preflight' options request in order to make sure the resource is valid, and that it has the right CORS access. This adds a default OPTIONS handler for all views. If a view needs to customize the OPTIONS handler for some reason, it's free to, but this way CORS will work.pull/2305/head
parent
65750f667b
commit
3fcc07af04
|
@ -443,3 +443,7 @@ class HomeAssistantView(object):
|
||||||
|
|
||||||
return self.Response(wrap_file(request.environ, fil),
|
return self.Response(wrap_file(request.environ, fil),
|
||||||
mimetype=mimetype, direct_passthrough=True)
|
mimetype=mimetype, direct_passthrough=True)
|
||||||
|
|
||||||
|
def options(self, request):
|
||||||
|
"""Default handler for OPTIONS (necessary for CORS preflight)."""
|
||||||
|
return self.Response('', status=200)
|
||||||
|
|
Loading…
Reference in New Issue