-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(amplify): add SPA redirect custom rule #7320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
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({ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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.
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
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). |
Commit Message
feat(amplify): add SPA redirect custom rule (#7320)
Refactor
CustomRuleto an enum-like class and add a static propertySINGLE_PAGE_APPLICATION_REDIRECTthat sets up a 200 rewrite for allfiles to
index.htmlexcept 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