
Javascript 経由で hood.ie に接続しようとしています:
hoodie = new Hoodie('http://example.com:6001');
しかし、エラーが発生します:A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'xxx' is therefore not allowed access.
と:
hoodie = new Hoodie('http://example.com');
404
...を与えます
localhost
public/admin の:6001
と :に接続できるので6002
、ポートは機能しています (外部の example.com の場合も同様)
しかし、devconsole では次のようになります:
OPTIONS: http://example.com:6001/_api/_session
'Access-Control-Allow-Origin'
資格情報フラグが true の場合、ヘッダーでワイルドカード '*' は使用できません。Origin 'http://example.com' したがってアクセスは許可されません。 `
Apache2を設定しました:
<VirtualHost *:80>
DocumentRoot /var/www
Header set Access-Control-Allow-Origin *
Header add Access-Control-Allow-Headers "origin, content-type"
Header always set Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"
Header set Access-Control-Allow-Credentials "false"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Header set Access-Control-Allow-Origin *
Header set Access-Control-Allow-Credentials "false"
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
さらにもう一つ試してみました:
<VirtualHost *:6001>
Header set Access-Control-Allow-Origin *
Header set Access-Control-Allow-Credentials "false"
</VirtualHost>
試したこと:
Header set Access-Control-Allow-Credentials false
Header set Access-Control-Allow-Credentials 'false'
Header set Access-Control-Allow-Credentials true
...etc
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Origin "example.com"
あらゆる可能なバリエーションを試しましたが、それでも同じエラーが発生します...
www
しかし、サービスのディレクトリはvar/www ではなくホーム フォルダー内のどこかにあるため、別の場所に設定する必要があるかどうか疑問に思っています。:6001
それでも機能しますが、Apache がそれをどのように処理するか、場所を認識するか、hood.ie が独自の Web サービスを開始するかどうかはわかりません。
答え1
私は次のようにすべきだと考えています:
Header set Access-Control-Allow-Origin "*"
他のAccess-Control-*フラグは使用せず、有効化-cors.org。
答え2
私は...するだろう推測「Hoodie」は、Cookie を送信する XMLHttpRequest (withCredentials = "true") を使用しており、許可されたオリジン ヘッダーにワイルドカードが含まれているため、ブラウザーはサーバーからの応答を拒否しています。