Skip to content
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

Serve default index.html file for folders #4

Open
watsonarw opened this issue Dec 20, 2021 · 0 comments
Open

Serve default index.html file for folders #4

watsonarw opened this issue Dec 20, 2021 · 0 comments

Comments

@watsonarw
Copy link
Owner

watsonarw commented Dec 20, 2021

There is a current limitation with this template where all paths must be referenced by the full file name, and not the directory name.

e.g a site with the path /foowhere /foo/index.html exists, does not serve the index.htmlfile and instead responds with the error file.

This is due to a limitation with Cloudfront, and the workaround is to use the bucket's web facing url, and point Cloudfront at the web origin instead of as an S3 origin. See this stackoverflow question.

Amazon's recommended fix is to use Lambda@Edge to rewrite the path when it gets the file from S3.

The response should be cached by Cloudfront, and only invoke the lambda on cache misses.

Acceptance Criteria

  1. Directories serve index.html with /
    Given I have a directory foo with an index.html file
    When I try to access the directory example.com/foo/ (with trailing /) via cloudfront
    Then I am served the foo/index.htmlfile

  2. Directories serve index.html without /
    Given I have a directory foo with an index.html file
    When I try to access the directory example.com/foo (without trailing /) via cloudfront
    Then I am served the foo/index.htmlfile

  3. Doesn't work without index.html
    Given I have a directory foo without an index.html file
    When I try to access the directory example.com/foo (without trailing /) via cloudfront
    Then I am served the error page

  4. Named files don't work as directories
    Given I have a file foo.html
    When I try to access the example.com/foo via cloudfront
    Then I am served the error page

  5. Named files don't work as directories with /
    Given I have a file foo.html
    When I try to access the example.com/foo/ via cloudfront
    Then I am served the error page

  6. Named files continue to work as files
    Given I have a file foo.html
    When I try to access the example.com/foo.html via cloudfront
    Then I am served the /foo.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant