aws-cdk-examples
aws-cdk-examples copied to clipboard
Static Site: GET /subdirectory should serve /subdirectory/index.html
It does not seem like subdirectory index files are served. Instead a GET /subdirectory responds with a 403
Hey @btakita,
Sorry for the delay, this was listed as a feature request (when it seems like a potential bug to me) and got passed over. A cursory look and I was unable to reproduce this.
A 403 Error strikes me as a potential permissions issue from your AWS configuration. Could you give me more reproduction steps? In particular, this example does not run out of the box and requires more information from the user.
It looks like the standard way to do the rewrite rule is to use lambda@edge. Problem with lambda@edge is that it's difficult to remove the functions once created. See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-delete-replicas.html
An alternative is to use CloudWatch. I have not tried it but seems easier to manage than lambda@edge. https://someguyontheinter.net/blog/serving-index-pages-from-a-non-root-location-via-cloudfront/
you can also do that creating a "subdirectory" file containing HTML and adding the text/html content type on S3
of course with this solution you cannot have other files or routes inside the "subdirectory"
a simpler solution could be to have a "subdirectory.html" path
If I am not wrong, having the URL "subdirectory" serving a "subdirectory/index.html" is not a specification, it comes from Apache rewrites or similar. It is a feature we are used to, not something that "should" be.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.