Restivus: XMLHttpRequest не может загрузить http://192.168.0.100:3000/api/tickets/2647179238671. Ответ на предпечатную проверку недействителен (перенаправление)
Я использую пакет Restivus в Meteor: https://github.com/kahmali/meteor-restivus
Я определил серверный маршрут на стороне сервера:
// Global API configuration
var Api = new Restivus({
useDefaultAuth: true,
prettyJson: true,
enableCors: true,
defaultHeaders: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Access-Control-Allow-Origin'
}
});
Api.addRoute('tickets/:number', {authRequired: false}, {
get: function () {
console.log('tickets-get');
},
});
И запрос:
const headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Access-Control-Allow-Origin'
};
HTTP.get('http://192.168.0.100:3000' + '/api/tickets/' + number, {headers: headers}, function(result) {
console.log('result', result);
});
И я получил эту ошибку:
XMLHttpRequest cannot load http://192.168.0.100:3000/api/tickets/2647179238671. Response for preflight is invalid (redirect)
app.js?hash=c3568aa253971056274151f1d8dc70f6d88ea3ac:49 result Error: network
at XMLHttpRequest.xhr.onreadystatechange (http://localhost:12992/packages/http.js?hash=18533e1caf7c942be3ecaa4dc168c938768df8ca:258:20)
Что я делаю неправильно?
РЕДАКТИРОВАТЬ: запросить заголовки из консоли Chrome:
General
Remote Address:192.168.0.100:3000
Request URL:http://192.168.0.100:3000/api/tickets/2647179238671
Request Method:OPTIONS
Status Code:302 Moved Temporarily
Response Headers
connection:keep-alive
date:Tue, 12 Apr 2016 21:33:41 GMT
location:https://localhost/api/tickets/2647179238671
transfer-encoding:chunked
Request Headers
Provisional headers are shown
Access-Control-Request-Headers:access-control-allow-headers, access-control-allow-origin
Access-Control-Request-Method:GET
Origin:http://localhost:12992
Referer:http://localhost:12992/
User-Agent:Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MHC19Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Crosswalk/17.46.448.10 Mobile Safari/537.36