AWS API Gateway CORS标头“ Access-Control-Allow-Origin”丢失

时间:2019-03-18 15:35:38

标签: javascript cors aws-api-gateway access-control

我目前面临有关从我的简单前端访问我在API网关中创建的API的问题。 如图所示,我已在使用的资源上启用了CORS:

enter image description here

这是我的请求的代码:

<script>
    new Vue({
        el: "#app",
        data: {
            eMail: '',
            password: ''
        },
        methods: {

            // API CALL HERE FOR INITIAL VALUES
            init() {},

            // SIGNUP
            signUp() {
                let userData = {
                    "mail": this.eMail,
                    "password": this.password
                }

                console.log(userData);

                const request = {
                    host: 'myapi.execute-api.eu-central-1.amazonaws.com',
                    method: 'POST',
                    url: `***********`,
                    data: userData, // object describing the foo
                    body: JSON.stringify(userData), // aws4 looks for body; axios for data   ...path: `/Prod/foos/${foo.id}`,
                    headers: {
                        'content-type': 'application/json',
                        'Access-Control-Allow-Origin': '*'
                    }
                };

                axios(request).then((response) => {
				if(!response.containsHeader("Access-Control-Allow-Origin"))
                    console.log(response);
                });

            }
        },
        mounted() {
            this.init();
        }
    });
</script>

使用脚本时,我在Firefox调试器中收到以下错误“ CORS标头'Access-Control-Allow-Origin'丢失”。我还没有找到解决这个问题的方法

0 个答案:

没有答案