0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Basic認証とBearer認証を一緒にすると 403エラーになる

Posted at

背景

  • ステージング環境用にBasic認証を導入
  • Bearer認証が必要なapiにリクエストするとエラー

原因

  • corsエラーを回避するためにorigin urlからリクエストを送るようにしている
  • Basic認証を導入するとAuthroizationにBasic認証のtokenが設定される

解決策

  • Bearer認証が必要なURLの場合は、Basic認証を付けない

例)

/api apiを送るURL
/^\/(?!api).*$/ 
↓
/apiが含まれるURLを除外する

例のようにBasic認証を外したいURLを除外するようにする。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?