私は生のファイルを隠すコードを取得するアプリケーションがあります。プライベート隠しリンクからテキストを取得
public getRawFile(rawLink: string) {
return this.http.get(rawLink).map((res: Response) => res.text());
}
をしかし、今、私は隠しRAWファイルからコードを取得したいと思いますが、プライベートリポジトリから:公共のリポジトリから廃棄することは簡単ですが、それはこのようになります。ユーザが生ファイルからのソースコードよりもアクセスしている(stashにログインしている)場合。
私は同じようにしようとしている場合は、私がrespone取得:
XMLHttpRequest cannot load 'private_stash_file_link'. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
EXCEPTION: Response with status: 0 for URL: null
Uncaught Response with status: 0 for URL: null
get要求のために、私はこれを処理することができますどのように、クッキー、特定のオプション、それも可能ですか?
EDITしようとしました。1.
:
public getRawFile(link: string) {
let headers = new Headers();
headers.append('Access-Control-Allow-Headers', 'Content-Type');
headers.append('Access-Control-Allow-Methods', 'GET, OPTIONS');
headers.append('Access-Control-Allow-Origin', '*');
let options = new RequestOptions({headers: headers, withCredentials: true});
return this.http.get(link, options).map((res: Response) => res.text());
}
が、同じ結果のプライベートリポジトリのを..
私は編集1のようにしようとしましたが、それ以外は何もできませんでした。今、私は公的なレポのためにhttpステータス400を取得しました。 – ulou
リクエストを受信しているサーバーにCORS設定がありますか? – pretzo246
https://plnkr.co/edit/ogDayyIOEbOLkI8XBzOX?p=preview – ulou