優先級的web-SDK的.login功能包括當使用下面的示例代碼的網頁返回一個錯誤請求的腳本:錯誤請求優先級的Web-SDK的功能的.login
<script
src="https://cdn.priority-software.com/upgrades/var/api/v1.5/priorityapp.nocache.js">
</script>
<script>
var config = {
url: 'https://www.eshbelsaas.com/ui/',
...
};
function priorityReady() {
login(config).then(
onsuccess=>
{
console.log('Your are in!! Enjoy!');
},
reason=>
{
console.log(reason.message);
}
</script>
全身體消息如下:
XMLHttpRequest無法加載www.eshbelsaas.com/.../service.svc。對預檢請求的響應不會通過訪問控制檢查:請求的資源上不存在「訪問控制 - 允許來源」標頭。因此不允許原產地'null'訪問。響應有HTTP狀態代碼400
同樣的行爲被展出:
- 鉻
- 邊緣
- 的JavaScript UWP應用
不過,我能NPM包在node.js中並使用相同的配置設置登錄:
var priority = require('priority-web-sdk');
var config = {
url: 'https://www.eshbelsaas.com/ui/',
...
};
priority.login(config)
.then(() => priority.formStart('CUSTOMERS', null, null, 'demo', 0))
.then(form => form.getRows(1))
.then(rows => console.log(rows))
.catch(err => console.log(err));
雖然在這一點上我得到一個權限錯誤。
Debugger listening on [::]:5858
{ type: 'apiError',
code: null,
message: 'Privilege required for \'Customers\' form (internal name = CUSTOMERS, company = Demo Company). Contact your system manager.',
form: null,
fatal: true }
更新2
按@leor |的評論我已經添加訪問控制頭到/ WCF一個V18服務器上。
telnet erpdemo.emerge-it.co.uk 80
GET /wcf/wcf/service.svc HTTP/1.1
HOST:erpdemo.emerge-it.co.uk
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 6437
Content-Type: text/html; charset=UTF-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS, HEAD
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Credentials: true
Date: Wed, 21 Jun 2017 10:42:04 GMT
...
不幸而clientUI不再出缺少訪問控制允許來源標題時,預檢仍然失敗:
XMLHttpRequest cannot load https://erpdemo.emerge-it.co.uk/wcf/wcf/service.svc.
Response for preflight has invalid HTTP status code 400
我可以確認需要什麼樣的頭,預檢,請?
感謝你! - 我試圖破解http重定向:[img](!http://tinypic.com/r/2hf6lup/9),但該程序包仍然檢測到302'd文件是從不同域到client.js。我使用的是VS,但我想我可以等到我們有了一個新的v18服務器來將客戶端放在與service.wcf相同的網址上。 –
@Leor你能詳細解釋一下嗎?當提到HTTP頭時,你是指Access-Control-Allow-Origin?你能解釋一下如何破壞CORS的目的嗎?如果我將Allow-Origin設置爲「my-other-domain.com」? 您可以分享更多關於如何設置網絡代理嗎?這將如何或多或少地安全? 我應該從你的回答中瞭解到優先級只支持優先級服務器內的API/SDK調用嗎?這感覺會限制爲我們的客戶創建服務的能力。 – Abe