在Odoo中,写控制器时http和https有什么区别?

问题描述

我在Odoo模块中安装了一个控制器。在基于 http 的调试环境中使用postman测试接口没有问题。但是,使用postman测试接口存在一些问题在基于 https 的生产环境中。

Python版本2.7.12

Odoo 10.0版

werkzeug版本0.11.11

这是我的代码。请帮助我,谢谢。

生产环境,协议为https。

controllers.py

# -*- coding:utf-8 -*-
from odoo.http import Controller
from odoo.http import route
from odoo.http import request

class PhotoPruner(Controller):
    @route('/<string:type>/photo/size/<int:record_id>',type='http',auth='none',methods=['GET'],csrf=False)
    def get_info(self,**kwargs):
        type = kwargs.get('type')
        record_id = kwargs.get('record_id')
        return 'ok'

邮递员测试

The result of postman test

记录错误信息

The picture of log error

调试环境,协议为http

没问题。

当我收到http://127.0.0.1/task/photo/size/146时我会收到'ok'

解决方法

Odoo路由支持两种类型的请求,httpjson。您可能会因为使用https(甚至不支持的一种类型)而在生产中出现错误。当您在Odoo应用程序之前使用Web服务器nginxapache并反向代理Odoo应用程序时,您可能在Web服务器和应用程序通信之间使用了http协议。检查您的nginx配置的proxy_pass,可能反向代理为http://127.0.0.1:8069(如果您是nginx或相应的apache虚拟主机配置行)。

有关Odoo Web控制器的更多信息,请参考Odoo的官方documentation,特别提到请求类型可以为httpjson

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...