2017-07-17 24 views
1

我有以下問題。當通過API網關運行我的openWhisk函數時,一切正常。也稱它爲跨域請求效果很好。有沒有人有關IBM OpenWhisk和Cors設置的想法?

但我需要用憑據調用它,似乎沒有選項來做到這一點。

我的嘗試:

  1. 剛剛啓用API CORS設置沒有任何標題的功能本身具有CORS標頭的功能以及API的UND
  2. 使CORS - >相關頭( access-origin)中的函數被覆蓋!
  3. 禁用API中CORS並具有功能CORS頭 - >功能的相關頭(訪問源)被刪除

這是正常應該工作的代碼:

return { 
 
     headers: { 
 
      'Access-Control-Allow-Headers': '*', 
 
      'Access-Control-Allow-Origin': domain, 
 
      'Access-Control-Allow-Credentials': 'true', 
 
      'Content-Type': 'text/xml' 
 
     }, 
 
     body: xml 
 
    }

將是巨大的,如果任何人有一個想法,因爲支持現在不回答我的多日票。

感謝和最誠摯,安德烈

+0

嘗試使用'WSK行動更新 -a TRUE'網絡的定製選項(參見https://github.com/apache /incubator-openwhisk/blob/master/docs/webactions.md#options-requests)。 – user6062970

+0

這聽起來像個好主意,但並不適合我。也可以使用.http結尾調用該函數作爲REST-APi,僅發送兩個訪問源標題(*,'http:// something') – FlipundFlop

+0

Bluemix支持根據與您的帳戶關聯的支持類型來確定優先級。有免費,基本,標準和高級水平。每個級別,票據嚴重程度和目標響應時間均記錄在以下URL中:https://console.bluemix.net/docs/support/index.html?pos=3#contacting-support –

回答

0

使用您的樣本:

> cat t.js 
function main() { 
return { 
     headers: { 
      'Access-Control-Allow-Headers': '*', 
      'Access-Control-Allow-Origin': 'domain', 
      'Access-Control-Allow-Credentials': 'true', 
      'Content-Type': 'text/xml' 
     }, 
     body: "<hi></hi>" 
    } 
} 

反對Bluemix:

> wsk action update t t.js -a web-custom-options true --web true 
ok: updated action t 

和冰壺網行動

> curl -v https://openwhisk.ng.bluemix.net/api/v1/web/myspace/default/t.http 
< HTTP/1.1 200 OK 
< X-Backside-Transport: OK OK 
< Connection: Keep-Alive 
< Transfer-Encoding: chunked 
< Server: nginx/1.11.13 
< Date: Tue, 18 Jul 2017 14:00:40 GMT 
< Content-Type: text/xml 
< Access-Control-Allow-Headers: * 
< Access-Control-Allow-Origin: domain 
< Access-Control-Allow-Credentials: true 
<hi></hi> 

沒有安浮選:

> wsk action update t t.js -a web-custom-options false --web true 

重複捲曲將顯示這些標題:

< Access-Control-Allow-Origin: *,domain 
< Access-Control-Allow-Methods: OPTIONS, GET, DELETE, POST, PUT, HEAD, PATCH 
< Access-Control-Allow-Headers: Authorization, Content-Type,* 
< Access-Control-Allow-Credentials: true 
相關問題