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="*")`
            這樣前端在進行接口調用的時候,就可以調通了,跨域問題就解決了。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章