2016-03-21 10 views
1

odooサーバーにionicアプリケーションでログインしようとしました。私は引用符で囲まれた誤りの下にある。それがCORSのためであれば、どのようにnginxを使わずにローカルのodooサーバで設定できますか?XMLHttpRequestは、odooサーバーへのionicログインでhttp:// localhost:8088/web/webclient/version_infoエラーを読み込めません。

XMLHttpRequest cannot load http://localhost:8088/web/webclient/version_info. Response to preflight request doesn't pass access control check: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8100' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute. 
+0

[ホワイトリスト](https://github.com/apache/cordova-plugin-whitelist.git)というプラグインを試してみてください – Webruster

答えて

1

cordova plugin add cordova-plugin-whitelist 

コルドバホワイトリストプラグインを追加

cordova prepare 

config.xmlの

<access origin="*"/> 

    <allow-intent href="*"/> 

    <allow-navigation href="http://*/*" /> 
にラインの下に追加を準備してください210

ブラウザ用のCORSでは、cmdまたはターミナルでchromeを開きます。 Windows用の

、MAC-OSX、

解決
open -a Google\ Chrome --args --disable-web-security --user-data-dir="/Users/thantshweaung/Documents/Project/ionic/chrome_cache" 

については

C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-agent="Android" --user-data-dir="C:/temp-chrome-eng 

+0

それは私のために働いた、ありがとう。 –

+0

それでは、この回答をアップに投票してください:) –

+1

すでに完了したフリオは、すでに完了しています。 –

0

localhostの代わりにIPアドレスを使用してください。例:デフォルトのブラウザで

http://192._._._:8088/web/webclient/version_info 
+0

実際に私はIPアドレスを使用しました。ありがとう。 –

1

は、セキュリティ上の理由から、クロスドメインの要求をブロックするように作られていますが、我々は様々な方法を、以下により作業クロスオリジン・リクエストをacheiveすることができます。

Chromeを開いてこのプラグインをインストールしてから、要求を送信しようとしてみてください。しかし、それは良い考えではありません。

https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=chrome-ntp-icon

セカンドアイデア

最善のことは、あなたのミドルウェアに行くと

としてヘッダを追加することで、「アクセス制御 - 許可 - 起源:*」

ことができるようになりますすべてのリクエストは異なるドメインから取得します。ノードのJsについては

+0

既にプラグインをインストールしておきました。しかし、まだエラー。 –

+0

一度インストールすると、クロムのCORSボタンが緑色に表示され、それが機能するだけで再起動します。 –

+0

と、その言語でnodejsの場合はサーバサイドコードを書いています。次にこれらのものを追加できます –

1

res.setHeader('Access-Control-Allow-Origin', '*'); 

// Request methods you wish to allow 
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); 

// Request headers you wish to allow 
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); 

// Set to true if you need the website to include cookies in the requests sent 
// to the API (e.g. in case you use sessions) 
res.setHeader('Access-Control-Allow-Credentials', true); 
関連する問題