Skip to content

Conversation

@jogold
Copy link
Contributor

@jogold jogold commented Apr 11, 2020

Commit Message

feat(amplify): add SPA redirect custom rule (#7320)

Refactor CustomRule to an enum-like class and add a static property
SINGLE_PAGE_APPLICATION_REDIRECT that sets up a 200 rewrite for all
files to index.html except for the following file extensions: css,
gif, ico, jpg, js, png, txt, svg, woff, ttf, map, json, webmanifest.

End Commit Message


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Refactor `CustomRule` to an enum-like class and add a static property
`SINGLE_PAGE_APPLICATION_REDIRECT` that sets up a 200 rewrite for all
files to `index.html` except for the following file extensions: css,
gif, ico, jpg, js, png, txt, svg, woff, ttf, map, json, webmanifest.
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 5e4c255
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 209c154
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

* following file extensions: css, gif, ico, jpg, js, png, txt, svg,
* woff, ttf, map, json, webmanifest.
*/
public static readonly SINGLE_PAGE_APPLICATION_REDIRECT = new CustomRule({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've always found these lists of extensions to be problematic. In my experience a custom redirect rule for all paths that don't contain an explicit file extension is much easier to deal with and wouldn't require us to maintain this ongoing list.

@jogold what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right... the regex comes from the docs at https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html and I already had to add the webmanifest extension.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully its relatively straightforward. I see this being relied on a lot. I'm actually surprised amplify doesn't have some solution built in for this behavior.

* following file extensions: css, gif, ico, jpg, js, png, txt, svg,
* woff, ttf, map, json, webmanifest.
*/
public static readonly SINGLE_PAGE_APPLICATION_REDIRECT = new CustomRule({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully its relatively straightforward. I see this being relied on a lot. I'm actually surprised amplify doesn't have some solution built in for this behavior.

@mergify mergify bot dismissed MrArnoldPalmer’s stale review May 4, 2020 12:35

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: e9af95e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented May 4, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: b94c560
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented May 4, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 0ef9883 into aws:master May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants