Search code examples
pythonxmlhttprequestcorsodooopenerp-7

How to configure CORS to OpenERP 7?


I am building a web service on OpenERP 7, using web controller. No problem when testing from POSTman, but on the website I get:

No 'Access-Control-Allow-Origin' header is present on the requested resource

I know it's a cross domains request issue, but I don't know how to configure CORS on OpenERP v7. In version 8 I can setup CORS on routing, but I have no idea how to configure it on v7.


Solution

  • Solved by calling werkzeug custom Response object:

    return werkzeug.wrappers.Response(json_response, headers=[('Access-Control-Allow-Origin', '*'), ('Content-Length', len(json_response))])