Browse Source

cors directive added

robert2206 8 năm trước cách đây
mục cha
commit
7a34fc0301
2 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      controllers/http_handler.py
  2. BIN
      controllers/http_handler.pyc

+ 3 - 3
controllers/http_handler.py

@@ -21,7 +21,7 @@ class Auth(http.Controller):
     # --------------------------------------------------------------------------
     # Generate JWT token based on username and password field
     # --------------------------------------------------------------------------
-    @http.route(['/api/jwt'], type = 'http', auth = 'none', methods = ['POST'])
+    @http.route(['/api/jwt'], type = 'http', auth = 'none', methods = ['POST'], cors = '*')
     def get_jwt(self, **args):
         try:
             user = request.env['res.users'].sudo().search([('login', '=', args['username']), ('active', '=', True)])
@@ -45,7 +45,7 @@ class Auth(http.Controller):
     # --------------------------------------------------------------------------
     # Check JWT token auth
     # --------------------------------------------------------------------------
-    @http.route(['/api/check'], type = 'http', auth = 'none')
+    @http.route(['/api/check'], type = 'http', auth = 'none', cors = '*')
     def check_token(self, **args):
         try:
             user = request.env['res.users'].sudo().search([('jwt_token', '=', args['token'])])
@@ -72,6 +72,6 @@ class Auth(http.Controller):
 '''
 class ApiManager(http.Controller):
 
-    @http.route(['/api/customers'], type = 'http', auth = 'none')
+    @http.route(['/api/customers'], type = 'http', auth = 'none', cors = '*')
     def customers(self):
         pass

BIN
controllers/http_handler.pyc