LoginSignup
0
0

More than 3 years have passed since last update.

org.springframework.web.servlet.handler.HandlerInterceptorAdapterでcors対応しようとしたらめっちゃ詰まった話

Last updated at Posted at 2020-04-20

HandlerInterceptorAdapterで認証をfirebaseで入れていた

クライアントサイドからのリクエストが延々とcorsエラー

止まらないエラー。

 「Access to fetch at 'http://localhost:8080/article/1/edit/fileupload' from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
」

cors対応はクライアントサイド、サーバサイドともにできている

クライアントサイド

fetchには、Requestに'cors'を設定できている。

サーバサイド

Spring Bootで、@CrosOriginつけている。

原因

HandlerInterceptorAdapterのpreHandle内で、

response.status = 200

などのステータスコードを設定していなかった。
根本原因は不明だが。。。

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