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