login.html:1 Failed to load http://larabbs.test/API/verificationCodes: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://test.im' is therefore not allowed access.

本地api服务器站点larabbs.test;另外本地创建了一个站点test.im,来访问larabbs.test的api接口,报错如下:

login.html:1 Failed to load http://larabbs.test/api/verificationCodes: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://test.im' is therefore not allowed access.

服务端env里这样设置的
API_STANDARDS_TREE=prs
API_SUBTYPE=WeAPP
我在js里这样写了

$.ajax({
                        url: 'http://larabbs.test/api/verificationCodes',
                        type: 'post',
                        headers: {
                            'Accept': 'application/prs.WeAPP.v1+json'
                        },
                        data: {
                        //获取用户填写手机号
                            phone: data.field.phone
                        },
                        success: function(data) {
                            console.log(data, 'success');
                        },
                        error: function(err) {
                            console.log(err, 'err');
                        },
                        complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数 
                            console.log(XMLHttpRequest, status, 'complete');
                        }
                    });

这是什么原因,应该怎么书写呢?

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 1

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!