首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cors策略不采用我指定的方法Express Gateway

Cors策略不采用我指定的方法Express Gateway
EN

Stack Overflow用户
提问于 2020-01-17 06:06:37
回答 1查看 159关注 0票数 0

我在angular有一个应用程序,我使用express gateway来控制我在backEnd端的请愿,除了我的Cors方法之外,一切都很好,我只想允许GET,PUT,POST,但即使我没有放DELETE方法它仍然可以访问,我不知道我哪里错了,我已经读过文档了。

代码语言:javascript
复制
{
"http": {
    "port": 8080,
},
"admin": {
    "port": 9876,
    "host": "localhost"
},
"apiEndpoints": {
    "apiAngular": {
        "host": "13.84.42.7",
        "paths": "/api/v3/*"
    },
    "api": {
        "host": "localhost",
        "paths": "/ip"
    }
},
"serviceEndpoints": {
    "service_apiAngular": {
        "url": "http://localhost:4002"
    },
    "httpbin": {
        "url": "https://httpbin.org"
    }
},
"policies": [
    "cors",
    "basic-auth",
    "expression",
    "key-auth",
    "log",
    "oauth2",
    "proxy",
    "rate-limit",
    "jwt"
],
"pipelines": {
    "pipeline_apiAngular": {
        "apiEndpoints": [
            "apiAngular"
        ],
        "policies": [
            {
                "cors":{
                    [
                        "action":{
                            "origin": "*",
                            "methods": "GET,PUT,POST",
                            "preflightContinue": false,
                            "optionsSuccessStatus": 204
                        }
                    ]

                }
            },
            {
                "rate-limit": [
                    {
                        "action": {
                            "max": 15,
                            "windowMs": 1200
                        }
                    }
                ]
            },
            {
                "proxy": [
                    {
                        "action": {
                            "serviceEndpoint": "service_apiAngular"
                        }
                    }
                ]
            }
        ]
    },
    "default": {
        "apiEndpoints": [
            "api"
        ],
        "policies": [
            {
                "proxy": [
                    {
                        "action": {
                            "serviceEndpoint": "httpbin",
                            "changeOrigin": true
                        }
                    }
                ]
            }
        ]
    }
}

}

EN

回答 1

Stack Overflow用户

发布于 2020-01-17 11:49:33

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSMethodNotFound

使用Access-Control- allow -Methods允许您想要允许的http请求方法

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59778519

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档