1
0

More than 3 years have passed since last update.

Amplifyアプリのリダイレクト設定をaws-cliで行う

Posted at

create-react-appとamplify-cliでアプリを作成していたところ、ここをみてリダイレクトの設定をしようと思ったのですが、AWS Consoleからしかできなくて調べました。
amplify-cliの設定でうまくやる方法が無いようでした1が、aws-cliではできました。

方法

まずリダイレクトのルールを書いたJSONファイルを作成します。

custom-rules.json
[{"source": "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>", "status": "200", "target": "index.html"}]

以下のようにappIdを指定してコマンドを実行します。

aws amplify update-app --app-id <appid> --custom-rules file://custom-rules.json

appIdは、以下のコマンドで確認できます。

aws amplify list-apps


  1. amplify-cliのソースでAWS.Amplify.createAppしているところで、CustomRulesのパラメタは渡していないので、今のところは無理っぽいと判断。 

1
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
1
0