The Movie Database サポート

Hi,

I'm having a problem with authentication. I want to have token validation by login in my Angular app, but when I make post request, it keeps sending option method (preflight request) and I get 404 error with "The Same Origin Policy disallows reading the remote resource...Reason: CORS preflight channel did not succeed). In Postman it works just fine and I have no problem getting session id there. Does this sound familiar?

7 replies (on page 1 of 1)

Jump to last post

What's an example pre-flight request that is failing? Most of them should be hooked up, so I would like to see which specifically is being called.

This is a security rule employed by most most moderns browsers in the CORS definition.

Basically, the OPTION preflight request will apply if :

  • Your request type is not GET, HEAD or POST
  • If it's a POST request, it will aply if your content-type header is not in : "application/x-www-form-urlencoded", "multipart/form-data", or "text/plain"

(I assume that your request is a POST with the content-type set to application/xml or application/json)

But it's not a problem, it's a safety measure. You just have to configure your server to respond to OPTION request with a status 200 and a header "Access-Control-Allow-Origin: *"

What is your backend setup ?

This is my post request

validateRequestToken(user){
       const httpOptions = {
        headers: new HttpHeaders({
        'Content-Type': 'application/json'}),
        };

     return this.http.post('https://api.themoviedb.org/3/authentication/token/validate_with_login?api_key=' + apiKey,  user, httpOptions).map(response =>{
        return new RequestToken(response); 
      })
 }

It sends pre-flight request, but it's not clear to me what should I do and is there a way to solve this without proxy and is this desirable behavior?

OPTIONS is enabled on most (was supposed to be all wink) endpoints but indeed, it was not enabled on the /3/authentication endpoints. I have a deploy going out later today that will enable it. I'll let you know when it's live.

Thank you very much for clarification and your help! ;)

OPTIONS should be enabled now on the /3/authentication methods. Let me know if you run into any more trouble.

Thanks Travis! ;-)

映画やテレビ番組が見つかりませんか?ログインして作成してください。

全般

s 検索バーに移動する
p プロファイルメニューを開く
esc 開いているウィンドウを閉じる
? キーボードショートカットウィンドウを開く

メディアのページ

b 戻る(または該当する場合は親に)
e 編集ページに行く

テレビ番組のシーズンのページ

(右矢印)次のシーズンに行く
(左矢印)前のシーズンに戻る

テレビ番組のエピソードのページ

(右矢印)次のエピソードに進む
(左矢印)前のエピソードに戻る

全ての画像のページ

a 画像追加ウィンドウを開く

全ての編集ページ

t 翻訳選択を開く
ctrl+ s フォームを送信する

ディスカッションのページ

n 新しいディスカッションを作成する
w 監視ステータスを切り替える
p 公開/非公開を切り替える
c 閉じる/開くを切り替える
a アクティビティを開く
r ディスカッションに返信
l 最後の返事に行く
ctrl+ enter メッセージを送信する
(右矢印)次のページ
(左矢印)前のページ

設定

このアイテムを評価したり、リストに追加したりしたいですか?

ログイン

メンバーではありませんか?

登録してコミュニティに参加