通过jamesdbloom / MockServer将PATCH添加到CORS的问题

时间:2018-10-03 13:31:20

标签: cors mockserver

我很难将PATCH方法添加到MockServer

我使用下面的curl请求,并且期望创建正确。

在测试时,我收到以下错误消息。

在飞行前响应中,Access-Control-Allow-Methods不允许使用方法PATCH。

我正在使用docker容器,并使用以下命令启动该容器。

docker run -p 1080:1080 jamesdbloom/mockserver /opt/mockserver/run_mockserver.sh -logLevel INFO -serverPort 1080 -genericJVMOptions '-Dmockserver.enableCORSForAllResponses=false'

我也尝试过

docker run -p 1080:1080 jamesdbloom/mockserver /opt/mockserver/run_mockserver.sh -logLevel INFO -serverPort 1080 -genericJVMOptions '-Dmockserver.enableCORSForAllResponses=true

curl -v -X PUT "http://localhost:1080/expectation" -d '{
    "httpRequest": {
      "method": "PATCH",
      "path": "/settings",
      "headers": {
          "Host": [".*"],
          "Connection": ["keep-alive"],
          "Origin": [".*"],
          "User-Agent": [".*"],
          "Access-Control-Request-Method": ["PATCH"],
          "access-control-request-headers": ["access-control-allow-origin,content-type"],
          "Accept.*": [".*"],
          "content-length": [".*"]
      },
      "body": {
          "type": "PARAMETERS",
          "parameters":                 
            {
              "email": ["user@example.com"],
              "name": ["User Name"],
              "password": ["supersecret"],
              "password_confirmation": ["supersecret"],
              "username": ["emanresu"]
          }
      }
    },
    "httpResponse": {
        "statusCode": 200,
        "headers": {
          "Content-Type": ["application/json"],
          "Server": ["nginx/1.13.12"],
          "Access-Control-Allow-Origin": ["*"],
          "Access-Control-Allow-Methods" : ["GET, HEAD, OPTIONS, POST, PUT, PATCH"],
          "Access-Control-Allow-Headers" : ["Access-Control-Allow-Origin, Authorization, Access-Control-Allow-Headers, Origin, Accept, X-Requested-With, Content-Type, Access-Control-Allow-Methods, Access-Control-Request-Method, Access-Control-Request-Headers"],
          "Access-Control-Expose-Headers": ["Access-Control-Allow-Origin, Authorization, Access-Control-Allow-Headers, Origin, Accept, X-Requested-With, Content-Type, Access-Control-Allow-Methods, Access-Control-Request-Method, Access-Control-Request-Headers"],
          "Access-Control-Max-Age": ["300"],
          "connection": ["close"]
        },
        "body": "{\"status\":\"success\"}"
    }
}'

0 个答案:

没有答案