LoginSignup
0
0

More than 1 year has passed since last update.

SpringBoot @CrossOriginの引数をapplication.propertiesから参照する

Last updated at Posted at 2023-03-21

概要

各コントローラークラスに付与される@CrossOriginの引数(URL)を一元的に管理するために、apllication.propertiesから参照するように設定します。

本番環境とローカル環境の切り替えを簡単に行うための改善です。

コード

〇〇Controller
@RestController
-@CrossOrigin(origins =  "http://127.0.0.1:3000")
+@CrossOrigin(origins =  "${frontend.URL}")
public class ProductRestController {

}
application.properties

+ frontend.URL = http://127.0.0.1:3000

参考

image.png

image.png

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