码迷,mamicode.com
首页 > 其他好文 > 详细

odoo Controller接口开发 POST请求的跨域问题解决方法

时间:2019-07-10 12:23:21      阅读:421      评论:0      收藏:0      [点我收藏+]

标签:led   type   called   rect   declare   官网   配置参数   strong   code   

odoo Controller接口开发 POST请求的跨域问题解决方法

1、odoo Controller接口开发,前端在请求的时候会发生跨域问题,报错信息如下:
Function declared as capable of handling request of type ‘json‘ but called with a request of type ‘http‘

2、解决方法如下:
      odoo官网给的参数解释: cors – The Access-Control-Allow-Origin cors directive value.

            可以在Controller接口上配置参数,如:
            `@http.route("/", type=‘json‘, auth="none", csrf=False, method=["POST"],
            website=True, cors="*")`
            这样前端在进行接口调用的时候,就可以调通了,跨域问题就解决了。

odoo Controller接口开发 POST请求的跨域问题解决方法

标签:led   type   called   rect   declare   官网   配置参数   strong   code   

原文地址:https://blog.51cto.com/siweilai/2418816

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!