使用基本身份验证时出现错误 404
Getting error 404 when use basic auth
我正在尝试使用 Fetch 进行 GET 查询,但在通过授权时收到错误 404。
我不知道为什么会出现这个错误,因为我使用像Postman这样的工具时服务器响应很好。
Authorization: Basic ...
method: GET
url: https://zammad.zonngo.com/api/v1/ticket_articles
当我使用 Javascript fetch API
时出现错误 404。
OPTIONS https://zammad.zonngo.com/api/v1/ticket_articles 404 (Not Found)
这是我的代码:
const myHeaders = new Headers();
myHeaders.append('Authorization','Basic ...');
myHeaders.append('Content-Type','application/json');
fetch(URLTICKETS, {
method: 'GET',
headers: myHeaders
})
.then(response => {
console.log(response);
})
.then(error => {
console.log(error);
});
如果有人能帮助我,那就太好了。
GET
方法URLreturns一个401状态码但是OPTIONS
方法实际上returns 一个 404。
http OPTIONS https://zammad.zonngo.com/api/v1/ticket_articles
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Thu, 02 Nov 2017 01:37:59 GMT
Server: nginx/1.10.3 (Ubuntu)
Transfer-Encoding: chunked
X-Request-Id: 16f58319-2658-4b0e-824c-08ca68e8d401
X-Runtime: 0.003135
OPTIONS
可能是由 https://zammad.zonngo.com/
似乎没有正确处理的 CORS 预检请求引起的。
https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
我正在尝试使用 Fetch 进行 GET 查询,但在通过授权时收到错误 404。
我不知道为什么会出现这个错误,因为我使用像Postman这样的工具时服务器响应很好。
Authorization: Basic ...
method: GET
url: https://zammad.zonngo.com/api/v1/ticket_articles
当我使用 Javascript fetch API
时出现错误 404。
OPTIONS https://zammad.zonngo.com/api/v1/ticket_articles 404 (Not Found)
这是我的代码:
const myHeaders = new Headers();
myHeaders.append('Authorization','Basic ...');
myHeaders.append('Content-Type','application/json');
fetch(URLTICKETS, {
method: 'GET',
headers: myHeaders
})
.then(response => {
console.log(response);
})
.then(error => {
console.log(error);
});
如果有人能帮助我,那就太好了。
GET
方法URLreturns一个401状态码但是OPTIONS
方法实际上returns 一个 404。
http OPTIONS https://zammad.zonngo.com/api/v1/ticket_articles
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Thu, 02 Nov 2017 01:37:59 GMT
Server: nginx/1.10.3 (Ubuntu)
Transfer-Encoding: chunked
X-Request-Id: 16f58319-2658-4b0e-824c-08ca68e8d401
X-Runtime: 0.003135
OPTIONS
可能是由 https://zammad.zonngo.com/
似乎没有正确处理的 CORS 预检请求引起的。
https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request