Single Page Application in AWS CloudFront
<p>I am having a Single Page static website which is hosted in AWS bucket.
The application is JavaScript.</p>

<p>I have setup Cloudfront for providing the content. 
The contents of the website is hosted in an AWS S3 bucket and Cloudfront is used to provide faster delivery of web content for users in different location.</p>

<p>But after setting up the website I am facing an issue. If I refresh the page, it will throw me the error as key is not present. 
I cannot refresh the page or copy the URL and paste it in another tab in the browser to access the same page.</p>

<p>I am getting the following error:</p>

<pre><code>&lt;Error&gt;
    &lt;Code&gt;NoSuchKey&lt;/Code&gt;
    &lt;Message&gt;The specified key does not exist.&lt;/Message&gt;
    &lt;Key&gt;__build__/home&lt;/Key&gt;
    &lt;RequestId&gt;36941111717B2006&lt;/RequestId&gt;   &lt;HostId&gt;wfLt17lDjXhZLqCxRM2zOiDIJSF03/HKdL3V9Oeq3r1glowmlZpavRj0zzBzBgXlXZudiXoc=&lt;/HostId&gt;
&lt;/Error&gt;
</code></pre>

<p>And my S3 buckets redirection rules are as follows:</p>

<pre><code>&lt;RoutingRules&gt;
    &lt;RoutingRule&gt;
        &lt;Condition&gt;
            &lt;KeyPrefixEquals&gt;*/&lt;/KeyPrefixEquals&gt;
        &lt;/Condition&gt;
        &lt;Redirect&gt;
            &lt;ReplaceKeyWith&gt;index.html&lt;/ReplaceKeyWith&gt;
        &lt;/Redirect&gt;
    &lt;/RoutingRule&gt;
&lt;/RoutingRules&gt;
</code></pre>