【发布时间】:2017-06-25 17:47:02
【问题描述】:
从我的 Angular 2 应用程序中,我尝试从 Moqui 获取数据,但请求总是失败并显示错误代码 403。
这里是 REST API 调用实现
获取示例(){ 让 url = 'http://localhost:8080/rest/s1/example/examples' let headers = new Headers({ '授权': '基本 am9obi5kb2U6bW9xdWk='}); headers.append('Accept', 'application/json, text/plain, */*'); headers.append('Content-Type', 'application/json; charset=UTF-8'); let options = new RequestOptions({ headers: headers }); 让 response = this.http.get(url, options).map(res => res.json()); 返回响应; }Moqui 日志:-
REST Access Forbidden (no authz): 用户 null 未被授权在 REST 路径 /example/examples 上查看
还有一个类似的问题Moqui Rest Nginx 但从答案中我不知道我必须在哪里更改 Moqui 中的设置。
在客户端控制台上的错误是:-
XMLHttpRequest 无法加载 http://localhost:8080/rest/s1/example/examples。预检响应包含无效的 HTTP 状态代码 403
【问题讨论】:
标签: moqui