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

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="*")`
            这样前端在进行接口调用的时候,就可以调通了,跨域问题就解决了。

猜你喜欢

转载自blog.51cto.com/siweilai/2418816