拒绝获取不安全的标头“x-parse-job-status-id” - Vue.js 和 Parse Server
Posted
技术标签:
【中文标题】拒绝获取不安全的标头“x-parse-job-status-id” - Vue.js 和 Parse Server【英文标题】:Refused to get unsafe header “x-parse-job-status-id” - Vue.js and Parse Server 【发布时间】:2018-08-08 08:31:46 【问题描述】:经过几个月的工作没有任何问题,现在尝试登录时,出现此错误。显示的代码被简化,当它到达“Parse.User.logIn”时就是错误发生的时候。这里有一些类似的问题,但都与 CORS 有关,它在本地服务器上运行正常,但是当我们托管它时,它不会返回数据并在控制台中显示错误为:
` Clud-Code>
Parse.Cloud.define("allUser", function (req, res)
var maxLevel, maxSponsor, topUser;
var max = [];
var topUserCount = 0;
var lastPayOut = [];
var connector = [];
var dataUT = [];
let UserTrack = Parse.Object.extend("UserTrack");
let UserDetails = Parse.Object.extend("UserDetails");
let Scheme = Parse.Object.extend("Scheme");
let SchemeRule = Parse.Object.extend("SchemeRule");
let qS = new Parse.Query(Scheme);
qS.equalTo("status", true);
qS.first().then((qSresult) =>
var currentScheme = new Scheme();
currentScheme.id = qSresult.id;
let qSR = new Parse.Query(SchemeRule);
qSR.equalTo("scheme", currentScheme);
qSR.find().then((qSRresult) =>
for (let sr = qSRresult.length; sr <= qSRresult.length; sr++)
maxLevel = qSRresult[sr - 1].get("level");
// maxTeam=qSRresult[sr].get("teamCount");
maxSponsor = qSRresult[sr - 1].get("sponsorCount");
// var maxAmount=qSRresult[sr].get("level");
let obj =
maxLevel,
maxSponsor
max.push(obj);
var level, team, joinee, repurchase, active;
let qUT = new Parse.Query(UserTrack);
qUT.descending("createdAt")
qUT.find().then((qUTresult) =>
for (let i of qUTresult)
level = i.get("level");
team = i.get("team");
joinee = i.get("sponsored");
repurchase = i.get("repurchase");
active = i.get("Active");
//top user logic
if ((level < max[0].maxLevel) && (joinee >=
max[0].maxSponsor))
topUserCount = topUserCount + 1;
let obj =
id: i.get("user").id,
date: i.get("createdAt"),
level: level,
// connector:qUDresult.get("connector").id,
team: team,
joinee: joinee,
repurchase: repurchase,
// lastPayOut:lastPayOut,
active: active
dataUT.push(obj);
topUser = topUserCount;
).then(() =>
let qUD = new Parse.Query(UserDetails);
qUD.descending("createdAt");
qUD.find().then((qUDresult) =>
for (let l = 0; l <= qUDresult.length - 1; l++)
let connectorU = qUDresult[l].get("connector").id;
let uId = qUDresult[l].get("user").id;
let objc =
connector: connectorU,
uId: uId,
id: dataUT[l].id,
date: dataUT[l].date,
level: dataUT[l].level,
team: dataUT[l].team,
joinee: dataUT[l].joinee,
repurchase: dataUT[l].repurchase,
active: dataUT[l].active
connector.push(objc);
//totalUser
var totalUser = connector.length;
var data = [connector, totalUser, topUser];
console.log(data);
res.success(data);
)
)
)
)
)
clien-side code->
Parse.User.logIn("ac0427d", "abcd1234");
Parse.Cloud.run('allUser',
).then((result) =>
console.log(result);
).catch((err) =>
console.log(err);
);
`
【问题讨论】:
您使用哪些域来访问应用程序? (本地和在 Heroku 上运行时)。localhost
被浏览器排除在 CORS 检查之外,因此您使用的任何域都可能在某处引入了对 CORS 策略的更改。
【参考方案1】:
您可能正在使用新版本的 SDK (2.0.0),与 1.x 相比,它包含许多重大更改,但您并不知情。
解决问题有两种可能:
使用昨天发布的 parse-server 2.8.3 通过将您的解析 SDK 版本指向:1.11.1 (https://unpkg.com/parse@1.11.1/dist/parse.js) 来使用正确的 SDK 版本(请参阅here)【讨论】:
以上是关于拒绝获取不安全的标头“x-parse-job-status-id” - Vue.js 和 Parse Server的主要内容,如果未能解决你的问题,请参考以下文章
拒绝获取不安全的标头“x-parse-job-status-id” - Vue.js 和 Parse Server
使用 Google Chrome 的 xmlHttpRequest 时拒绝设置不安全的标头“Origin”